public async Task <UtilisateurRole> AjouterUtilisateurRole(UtilisateurRole utilisateurRole)
        {
            if (utilisateurRole == null)
            {
                throw new UtilisateurRoleNotFoundException();
            }

            context.UtilisateurRole.Add(utilisateurRole);
            await context.SaveChangesAsync();

            return(utilisateurRole);
        }
Beispiel #2
0
        public async Task <Commentaire> AjouterCommentaire(Commentaire commentaire)
        {
            if (commentaire == null)
            {
                throw new CommentaireNotFoundException();
            }

            context.Commentaire.Add(commentaire);
            await context.SaveChangesAsync();

            return(commentaire);
        }
Beispiel #3
0
        public async Task <LigneProduit> AjouterLigneProduit(LigneProduit ligneProduit)
        {
            if (ligneProduit == null)
            {
                throw new LigneProduitNotFoundException();
            }

            context.LigneProduit.Add(ligneProduit);
            await context.SaveChangesAsync();

            return(ligneProduit);
        }
Beispiel #4
0
        public async Task <LigneCommande> AjouterLigneCommande(LigneCommande ligneCommande)
        {
            if (ligneCommande == null)
            {
                throw new LigneCommandeNotFoundException();
            }

            context.LigneCommande.Add(ligneCommande);
            await context.SaveChangesAsync();

            return(ligneCommande);
        }
Beispiel #5
0
        public async Task ModifierBox(Box box, BoxDTO boxDTO)
        {
            box.Id  = boxDTO.Id;
            box.Nom = boxDTO.Nom;
            box.PrixUnitaireHtva = boxDTO.PrixUnitaireHtva;
            box.Tva          = boxDTO.Tva;
            box.Promotion    = boxDTO.Promotion;
            box.Description  = boxDTO.Description;
            box.Photo        = boxDTO.Photo;
            box.Affichable   = boxDTO.Affichable;
            box.DateCreation = boxDTO.DateCreation;
            context.Entry(box).OriginalValues["RowVersion"] = boxDTO.RowVersion;

            await context.SaveChangesAsync();
        }
Beispiel #6
0
        public async Task <Utilisateur> AjouterUtilisateur(Utilisateur utilisateur)
        {
            if (utilisateur == null)
            {
                throw new UtilisateurNotFoundException();
            }

            context.Utilisateur.Add(utilisateur);

            UtilisateurRoleDAO utilisateurRoleDAO = new UtilisateurRoleDAO(context);

            await context.SaveChangesAsync();

            await utilisateurRoleDAO.AjouterDefaultRole(utilisateur);

            return(utilisateur);
        }
Beispiel #7
0
        public async Task <Produit> AjouterProduit(Produit produit)
        {
            if (produit == null)
            {
                throw new ProduitNotFoundException();
            }

            context.Produit.Add(produit);
            await context.SaveChangesAsync();

            return(produit);
        }
Beispiel #8
0
        public async Task <Commande> AjouterCommande(Commande commande)
        {
            if (commande == null)
            {
                throw new CommandeNotFoundException();
            }

            context.Commande.Add(commande);
            await context.SaveChangesAsync();

            LigneCommandeDAO ligneCommandeDAO = new LigneCommandeDAO(context);

            foreach (var ligneCommande in commande.LigneCommande)
            {
                await ligneCommandeDAO.AjouterLigneCommande(ligneCommande);
            }

            return(commande);
        }
Beispiel #9
0
        public async Task <Adresse> AjouterAdresse(Adresse adresse)
        {
            if (adresse == null)
            {
                throw new AdresseNotFoundException();
            }

            Adresse adresseExiste = await GetAdresseByAdresse(adresse);

            if (adresseExiste != null)
            {
                return(adresseExiste);
            }

            context.Adresse.Add(adresse);
            await context.SaveChangesAsync();

            return(adresse);
        }