public async Task<Produit> GetProduit(AKeyUidRnoNo key, DateTime date) { Produit produit = new Produit { Uid = key.Uid, Rno = key.Rno, No = key.No }; IQueryable<EtatProduit> états = _context.EtatProduit.Where(ep => key.EstSemblable(ep) && ep.Date < date); produit.Nom = await états .Where(ep => ep.Nom != null) .Select(ep => ep.Nom) .LastAsync(); produit.TypeCommande = await états .Where(ep => ep.TypeCommande != null) .Select(ep => ep.TypeCommande) .LastAsync(); produit.TypeMesure = await états .Where(ep => ep.TypeMesure != null) .Select(ep => ep.TypeMesure) .LastAsync(); produit.Prix = await états .Where(ep => ep.Prix != null) .Select(ep => ep.Prix?? 0) .LastAsync(); return produit; }
public Vérificateur(ParamsSupprimeCommande paramsSupprime) { KeyClient = AKeyUidRnoNo.KeyUidRno(paramsSupprime); KeyCommande = paramsSupprime; NoLivraison = paramsSupprime.NoLivraison; DateCatalogue = paramsSupprime.DateCatalogue; }
public async Task <Commande> LitCommande(AKeyUidRnoNo keyCommande) { Commande commande = await _context.Commande .Where(d => d.AMêmeKey(keyCommande)) .FirstOrDefaultAsync(); return(commande); }
/// <summary> /// retourne la commande définie par keyOuVueCommande /// </summary> /// <param name="keyOuVueCommande"></param> /// <returns></returns> public async Task <Commande> CommandeDeKeyOuVue(AKeyUidRnoNo keyOuVueCommande) { bool filtre(Commande c) => c.Uid == keyOuVueCommande.Uid && c.Rno == keyOuVueCommande.Rno && c.No == keyOuVueCommande.No; Commande commande = await _utile.CommandesAvecDétailsLivraisonEtFacture(filtre, null, null, null) .FirstOrDefaultAsync(); return(commande); }
/// <summary> /// Lit la commande définie par vérificateur.KeyCommande et vérifie qu'elle existe. Fixe vérificateur.Commande. /// </summary> /// <param name="vérificateur"></param> /// <returns></returns> private async Task CommandeExiste(Vérificateur vérificateur) { AKeyUidRnoNo key = vérificateur.KeyCommande; Func <Commande, bool> filtre = (Commande c) => c.Uid == key.Uid && c.Rno == key.Rno && c.No == key.No; Commande commande = await _utile.CommandesAvecDétailsLivraisonEtFacture(filtre, null, null, null).FirstOrDefaultAsync(); if (commande == null) { vérificateur.Erreur = RésultatBadRequest("CommandeNExistePas"); return; } vérificateur.Commande = commande; }
public async Task <Catégorie> GetCatégorie(AKeyUidRnoNo key, DateTime date) { Catégorie catégorie = new Catégorie { Uid = key.Uid, Rno = key.Rno, No = key.No }; IQueryable <EtatCatégorie> états = _context.EtatCatégorie.Where(ec => key.EstSemblable(ec) && ec.Date < date); catégorie.Nom = await états .Where(ec => ec.Nom != null) .Select(ec => ec.Nom) .LastAsync(); return(catégorie); }
private async Task <IActionResult> Document(KeyUidRnoNo keyDocument, Func <Site, KeyUidRnoNo, Task <AKeyUidRnoNo> > litDocument) { CarteUtilisateur carte = await _utilisateurService.CréeCarteUtilisateur(HttpContext.User); if (carte == null) { // fausse carte return(Forbid()); } KeyUidRno keyClient = new KeyUidRno { Uid = keyDocument.Uid, Rno = keyDocument.Rno }; Site site = await _utile.SiteDeClient(keyClient); if (site == null) { return(NotFound()); } if (!await carte.EstActifEtAMêmeUidRno(site.KeyParam)) { // l'utilisateur n'est pas le fournisseur if (!carte.EstClient(site)) { return(Forbid()); } } AKeyUidRnoNo document = await litDocument(site, keyDocument); if (document == null) { return(NotFound()); } return(Ok(document)); }
public async Task<bool> NomPrisParAutre(AKeyUidRnoNo key, string nom) { return await _dbSet.Where(produit => produit.Nom == nom && (produit.Uid != key.Uid || produit.Rno != key.Rno || produit.No != key.No)).AnyAsync(); }
public async Task <bool> NomPrisParAutre(AKeyUidRnoNo key, string nom) { return(await _dbSet.Where(Catégorie => Catégorie.Nom == nom && (Catégorie.Uid != key.Uid || Catégorie.Rno != key.Rno || Catégorie.No != key.No)).AnyAsync()); }