using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Modèle
{
    public class Utilisateur : Personne
    {
        public int NbSubmit { get; private set; }
        public Utilisateur(string mail, string mdp): base(mail, mdp)
        {
            NbSubmit = 0;
        }
        public Utilisateur(string mail, string mdp, int nbSubmit): base(mail, mdp) 
        {
            NbSubmit = nbSubmit;
        }

        public override string ToString()
        {
            return Email + " " + MotDePasse + " " + NbSubmit;
        }
        public int FaireUnSubmit(string nom, string nomSci, string desc, string photo, string video, string photoCarte, Conservation cons, List<Zone> rep, string funFact, List<Requin> lBdPasFinie)
        {
            Requin petitNouveau = new Requin(nom, nomSci, desc, photo, video, photoCarte, cons, rep, funFact);
            lBdPasFinie.Add(petitNouveau);
            NbSubmit++;
            return 1;
        }

        public void FaireUnChangement(Requin req, string desc, string photo, string video, string photoCarte, Conservation cons, List<Zone> rep, string funFact, List<Requin> lBdPasFinie){
            if (string.IsNullOrWhiteSpace(desc))
            {
                desc = req.Description;
            }
            if (string.IsNullOrWhiteSpace(photo))
            {
                photo = req.Photo;
            }
            if (string.IsNullOrWhiteSpace(video))
            {
                video = req.Video;
            }
            if (string.IsNullOrWhiteSpace(photoCarte))
            {
                photoCarte = req.PhotoCarte;
            }
            if (cons == Conservation.NE)
            {
                cons = req.StatutCons;
            }
            if (string.IsNullOrWhiteSpace(funFact))
            {
                funFact = req.FunFact;
            }
            if (rep.Count() == 0)
            {
                foreach (Zone z in req.Repartition)
                {
                    rep.Add(z);
                }
            }
            Requin requin = new Requin(req.Nom, req.NomSci, desc, photo, video, photoCarte, cons, rep, funFact);
            lBdPasFinie.Add(requin);
            NbSubmit++;
        }


        public bool Equals(Utilisateur u)
        {
            return Email == u.Email;
        }
    }
}
