예제 #1
0
        public static Client GetItem(int id)
        {
            Client client = ClientDAL.GetItem(id);

            return(client);
        }
예제 #2
0
        public static List <Client> GetList()
        {
            List <Client> clients = ClientDAL.GetList();

            return(clients);
        }
예제 #3
0
        static void Main()
        {
            var context = new LojaZeroDbContextFactory().CreateDbContext();

            var pro = new ProductDAL(context);

            var cli = new ClientDAL(context);

            var product = new Product()
            {
                Name        = "sorvete",
                Description = "sorvete muito bom",
                Stock       = 10,
                Value       = 1.3m,
                Weight      = 1,
                ProductTags = new List <ProductTag>()
                {
                    new ProductTag()
                    {
                        Tag = new Tag()
                        {
                            Name = "Comida"
                        }
                    },
                    new ProductTag()
                    {
                        Tag = new Tag()
                        {
                            Name = "delicia"
                        }
                    }
                }
            };

            var client = new Client()
            {
                FirstName  = "Felipe",
                LastName   = "pinheiro",
                CPF        = "012.109.651-35",
                DtBirthDay = new DateTime(1985, 5, 1),
                Gender     = Gender.Male,
                User       = new UserPerson()
                {
                    Email    = "*****@*****.**",
                    Password = "******"
                },
                Phones = new List <Phone>()
                {
                    new Phone()
                    {
                        AreaCode    = 61,
                        CountryCode = 55,
                        Number      = 995599415
                    }
                },
                Addresses = new List <Address>()
                {
                    new Address()
                    {
                        Country  = "brasil",
                        State    = "DF",
                        City     = "Brasilia",
                        District = "taguatiga",
                        Number   = 25,
                        Street   = "qnb 03",
                        ZipCode  = 72115030
                    }
                }
            };

            pro.Create(product);
            cli.Create(client);

            Console.WriteLine(pro.Exist(1));
        }
예제 #4
0
        private void CreateRoomForm_Load(object sender, EventArgs e)
        {
            ClientDAL.GetInstance().Register(new ClientDAL.ShowHandler(this.showRoom));

            ClientDAL.GetInstance().SendMessage("ShowRoom," + UserHelper.sceneId);
        }
예제 #5
0
        protected override void Initialize(RequestContext requestContext)
        {
            base.Initialize(requestContext);

            ActionNom     = RouteData.Values["action"].ToString();
            ControllerNom = RouteData.Values["controller"].ToString();
            MettrelUrlEnSession();

            if (Session["ClientId"] == null || (int)Session["ClientId"] == 0)
            {
                HttpCookie cookie = Request.Cookies.Get("GuidClient");
                if (cookie != null && (Client = new ClientDAL().ConnexionCookies(cookie.Value)) != null)
                {
                    ViewBag.Client      = Client;
                    Session["ClientId"] = Client.Id;
                    PanierViewModel     = new PanierViewModel(); //Todo effacer
                    AgregerPanierEnBase();
                    RecupererPanierEnBase();
                }
                else
                {
                    Session["ClientId"] = 0;
                    ViewBag.Client      = Client = new Client();
                }
            }
            else
            {
                ViewBag.Client = Client = new ClientDAL().Details((int)Session["ClientId"]);
            }

            new PanierDAL(Client.Id).SupprimerArticlesPasDansCarte();
            VisiteDAL.Enregistrer(Client.Id);
            if (Client.Id != 0)
            {
                DonnerLesDroitsdAcces();
                PanierViewModel = new PanierViewModel(new PanierDAL(Client.Id).ListerPanierClient());
            }
            else
            {
                RetirerLesDroitsdAcces();
                if (Session["ProspectGuid"] != null)
                {
                    ProspectGuid = Session["ProspectGuid"].ToString();
                }
                else
                {
                    HttpCookie cookie = Request.Cookies.Get("Prospect");
                    if (cookie != null)
                    {
                        Session["ProspectGuid"] = ProspectGuid = cookie.Value;
                        List <PanierProspect> paniers = new PanierProspectDAL(ProspectGuid).ListerPanierProspect();
                        if (paniers.Count > 0)
                        {
                            RecupererPanierEnBase();
                        }
                    }
                    else
                    {
                        string guid = Guid.NewGuid().ToString();
                        Session["ProspectGuid"] = ProspectGuid = guid;
                        cookie = new HttpCookie("Prospect")
                        {
                            Value   = guid,
                            Expires = DateTime.Now.AddDays(30)
                        };
                        Response.Cookies.Add(cookie);
                    }
                }
                new PanierProspectDAL(ProspectGuid).SupprimerArticlesPasDansCarte();
                PanierViewModel = new PanierViewModel(new PanierProspectDAL(ProspectGuid).ListerPanierProspect());
            }
            PanierViewModel.Trier();
            ViewBag.Panier = PanierViewModel;

            if (Client.AdminArticle || Client.AdminCommande || Client.AdminClient || Client.AdminPlanning)
            {
                ViewBag.MenuAdmin = true;
            }
            if (Client.AdminArticle)
            {
                ViewBag.AdminArticle = true;
            }
        }
예제 #6
0
 public static ObservableCollection <Client> GetAll()
 {
     return(ClientDAL.GetAll());
 }
예제 #7
0
        public bool DeleteClientBL(ClientModel _ClientModel)
        {
            bool result = ClientDAL.DeleteClient(_ClientModel);

            return(result);
        }
예제 #8
0
        // Deleteing the client. -> only from the admin area.
        //Delete all the assoicated data.

        public static bool Delete(Client client)
        {
            return(ClientDAL.Delete(client.CLientId));
        }
예제 #9
0
        public bool InsertClientBL(ClientModel _ClientModel)
        {
            bool result = ClientDAL.InsertClient(_ClientModel);

            return(result);
        }
예제 #10
0
        public bool UpdateClientBL(ClientModel _ClientModel)
        {
            bool result = ClientDAL.UpdateClient(_ClientModel);

            return(result);
        }
예제 #11
0
 public static ObservableCollection <Client> ClientLocalidade()
 {
     return(ClientDAL.ClientLocalidade());
 }
예제 #12
0
 public static ObservableCollection <Registration> ClienteRegistado()
 {
     return(ClientDAL.ClienteRegistado());
 }
예제 #13
0
        public bool CheckRegistration(long id)
        {
            bool res = ClientDAL.CheckRegistration(id);

            return(res);
        }
예제 #14
0
 public static int Insert(Client client)
 {
     client.CLientId = ClientDAL.Insert(client);
     return(client.CLientId);
 }
예제 #15
0
 public ClientBL()
 {
     clientDAL = new ClientDAL();
 }
예제 #16
0
 public static int Update(Client client)
 {
     client.CLientId = ClientDAL.Update(client);
     return(client.CLientId);
 }
예제 #17
0
        public ActionResult OubliMotDePasse(string action, string email, string mdp, string mdp2)
        {
            if (action == "generationMail")
            {
                int    dureeValidite    = int.Parse(ConfigurationManager.AppSettings["DureeValiditeLienReinitialisationMotDePasse"]);
                string codeVerification = Guid.NewGuid().ToString("n") + email.GetHash();
                string url    = HttpContext.Request.Url.ToString() + '/' + codeVerification;
                Client client = new ClientDAL().Details(email);
                if (client != null)
                {
                    DateTime finValidite       = DateTime.Now.AddMinutes(dureeValidite);
                    string   stringFinValidite = finValidite.ToString("dddd dd MMMM yyyy à HH:mm").Replace(":", "h");
                    new OubliMotDePasseDAL().Ajouter(client.Id, codeVerification, DateTime.Now.AddMinutes(dureeValidite));
                    string sujetMail = "Procédure de réinitialisation de votre mot de passe";
                    string message   = "Bonjour\n" +
                                       "Vous avez oublié votre mot de passe et avez demandé à le réinitialiser.\n" +
                                       "Si vous êtes bien à l'origine de cette demande, veuillez cliquer sur le lien suivant ou recopier l'adresse dans votre navigateur :\n" +
                                       "\n" +
                                       url +
                                       "\n\nVous serez alors redirigé vers une page de réinitialisation de votre mot de passe.\n" +
                                       $"Attention, ce lien expirera le {stringFinValidite} et n'est valable qu'une seule fois";

                    if (Utilitaire.EnvoieMail(email, sujetMail, message))
                    {
                        TempData["message"] = new Message($"Un email de réinitialisation de votre mot de passe vient de vous être envoyé.\nIl expirera dans {dureeValidite} minutes.", TypeMessage.Info);
                    }
                    else
                    {
                        TempData["message"] = new Message("Erreur dans l'envoi du mail.\nVeuillez réessayer dans quelques instants", TypeMessage.Erreur);
                    }
                }
                else
                {
                    TempData["message"] = new Message("Nous n'avons pas de compte client avec cette adresse email.\nMerci de vérifier votre saisie", TypeMessage.Erreur);
                }

                return(RedirectToAction("Connexion", "Compte"));
            }
            else if (action == "changementMotDePasse")
            {
                if (VerifMdp(mdp, mdp2))
                {
                    ClientDAL clientDAL = new ClientDAL();
                    if (clientDAL.Modification(Client.Id, mdp) == 1)
                    {
                        TempData["message"] = new Message("La modification de votre mot de passe a bien été prise en compte", TypeMessage.Ok);
                    }
                }
                else
                {
                    TempData["message"] = new Message("Mauvais choix de mots de passe.\nVeuillez réessayer (minimum 8 caractères et identiques)", TypeMessage.Erreur);
                    return(View());
                }

                CommandeDAL commandeDAL = new CommandeDAL();
                ViewBag.RemiseTotalClient = commandeDAL.RemiseTotaleClient(Client.Id);
                return(RedirectToAction("Connexion", "Compte"));
            }
            else
            {
                return(RedirectToAction("Connexion", "Compte"));
            }
        }
예제 #18
0
        public ActionResult Index(string codePromo, DateTime dateRetrait, int?remiseFidelite)
        {
            if (PanierViewModel.ArticlesDetailsViewModel.Count == 0)
            {
                return(View(new Commande()));
            }
            else
            {
                #region commandes restantes
                //int maxCommandesHeure = int.Parse(ConfigurationManager.AppSettings["NombreDeCommandesMaxParHeure"]);
                //int pasCreneauxHoraire = int.Parse(ConfigurationManager.AppSettings["PasCreneauxHoraire"]);
                //int maxCommandesCreneau = (int)Math.Ceiling((double)maxCommandesHeure * pasCreneauxHoraire / 60);
                //int commandesPossiblesRestantes = maxCommandesCreneau - new CommandeDAL().NombreCommandes(dateRetrait);
                #endregion
                int montantRemiseFidelite = remiseFidelite ?? 0;
                new CodePromoDAL().Validite(codePromo, PanierViewModel.PrixTotalTTC, out double montantRemiseCommerciale);

                if (montantRemiseFidelite != 0 && Client.Id != 0)
                {
                    int soldeCagnotte = new ClientDAL().RetirerCagnotte(Client.Id, montantRemiseFidelite);
                    if (soldeCagnotte == -1)
                    {
                        montantRemiseFidelite = 0;
                    }
                }
                Commande commande = new Commande
                {
                    ClientId          = Client.Id,
                    DateCommande      = DateTime.Now,
                    DateRetrait       = dateRetrait,
                    PrixTotalTTC      = 0,
                    RemiseFidelite    = montantRemiseFidelite,
                    RemiseCommerciale = montantRemiseCommerciale
                };
                foreach (ArticleViewModel article in PanierViewModel.ArticlesDetailsViewModel)
                {
                    commande.PrixTotalTTC = Math.Round(commande.PrixTotalTTC + article.Article.PrixTTC * article.Quantite, 2);
                    new ArticleDAL().AugmenterQuantiteVendue(article.Article.Id, 1);
                }
                if (commande.PrixTotalTTC > montantRemiseFidelite + montantRemiseCommerciale)
                {
                    commande.PrixTotalTTC = Math.Round(commande.PrixTotalTTC - montantRemiseFidelite - montantRemiseCommerciale, 2);
                }
                else
                {
                    commande.RemiseCommerciale = Math.Round(commande.PrixTotalTTC - montantRemiseFidelite, 2);
                    commande.PrixTotalTTC      = 0;
                }

                new CommandeDAL().Ajouter(commande, PanierViewModel.ArticlesDetailsViewModel);
                MailCommande(Client, commande, PanierViewModel);
                new PanierDAL(Client.Id).Supprimer();
                ViewBag.Panier = null; //todo

                string      stringDateRetrait = commande.DateRetrait.ToString("dddd dd MMMM yyyy pour HH:mm");
                string      message           = $"Commande numéro {commande.Id} confirmée\nVeuillez venir la chercher le {stringDateRetrait}.";
                TypeMessage typeMessage;
                if (Client.Id == 0)
                {
                    message    += $"\nAttention : Vous n'avez pas utilisé de compte client.\nMerci de bien noter votre numéro de commande.";
                    typeMessage = TypeMessage.Avertissement;
                }
                else
                {
                    message    += "\nMerci";
                    typeMessage = TypeMessage.Ok;
                }
                TempData["message"] = new Message(message, typeMessage);
                return(RedirectToAction("Index", "Home"));
            }
        }
예제 #19
0
        public ActionResult Profil(string ancienEmail, string login, string email, string ancienMdp, string nom, string prenom, string telephone, string mdp, string mdp2)
        {
            ViewBag.Login     = login;
            ViewBag.Email     = email;
            ViewBag.Nom       = nom;
            ViewBag.Prenom    = prenom;
            ViewBag.Telephone = telephone;
            ViewBag.Mdp       = mdp;
            ViewBag.AncienMdp = ancienMdp;

            StringBuilder messageFabrique = new StringBuilder();

            ClientDAL clientDAL = new ClientDAL();
            Client    client    = clientDAL.Connexion(ancienEmail, ancienMdp);
            bool      erreur    = false;

            if (client == null)
            {
                messageFabrique.Append("L'ancien mot de passe n'est pas correct.");
                erreur            = true;
                ViewBag.AncienMdp = "";
            }
            else
            {
                int verifClientId = clientDAL.ExisteLogin(login);
                if (verifClientId != 0 && verifClientId != Client.Id)
                {
                    ViewBag.Login = "";
                    messageFabrique.Append("Le nouveau nom d'utilisateur est déjà utilisé.\n");
                    erreur = true;
                }
                verifClientId = clientDAL.ExisteEmail(email);
                if (verifClientId != 0 && verifClientId != Client.Id)
                {
                    ViewBag.Email = "";
                    messageFabrique.Append("Le nouvel Email est déjà utilisé.\n");
                    erreur = true;
                }
                string nouveauMdp = "";
                if (mdp == "" && mdp2 == "")
                {
                    nouveauMdp = ancienMdp;
                }
                else if (VerifMdp(mdp, mdp2))
                {
                    nouveauMdp = mdp;
                }
                else
                {
                    ViewBag.Mdp = "";
                    messageFabrique.Append("Mauvais choix de mots de passe. (minimum 8 caractères et identiques)");
                    erreur = true;
                }
                if (!erreur)
                {
                    if (clientDAL.Modification(client.Id, nouveauMdp, login, email, nom, prenom, telephone) == 1)
                    {
                        messageFabrique.Append("La modification du profil a bien été prise en compte.");
                        Client = clientDAL.Connexion(email, nouveauMdp);
                    }
                    else
                    {
                        messageFabrique.Append("Une erreur s'est produite lors de la mise à jour de vos données");
                        erreur = true;
                    }
                }
            }
            string message = messageFabrique.ToString();

            if (erreur)
            {
                TempData["message"] = new Message(message, TypeMessage.Erreur);
            }
            else
            {
                TempData["message"] = new Message(message, TypeMessage.Ok);
            }

            CommandeDAL commandeDAL = new CommandeDAL();

            ViewBag.RemiseTotalClient = commandeDAL.RemiseTotaleClient(Client.Id); //todo vérifier si code utile
            return(View(Client));
        }
예제 #20
0
        public ActionResult DeleteAccount(int id)
        {
            ClientModel model = ClientDAL.GetClient(id);

            return(View(model));
        }
예제 #21
0
 public bool Update()
 {
     return(ClientDAL.Update(this));
 }