public async Task <IActionResult> Create([Bind("Id,Numero,Commentaire,FournisseurId")] CommandeFournisseurEntity commandeFournisseurEntity) { if (ModelState.IsValid) { await _service_commande_fournisseur.Add(commandeFournisseurEntity); return(RedirectToAction("Edit", new { Id = commandeFournisseurEntity.Id })); } ViewData["FournisseurId"] = new SelectList(_context.FournisseurEntities, "Id", "Id", commandeFournisseurEntity.FournisseurId); ViewData["NomCommandeFournisseurStatutId"] = new SelectList(_context.NomCommandeFournisseurStatutEntities, "Id", "Code", commandeFournisseurEntity.NomCommandeFournisseurStatutId); return(View(commandeFournisseurEntity)); }
public async Task <IActionResult> ValiderCommande(CommandeDTO _dto) { AdresseEntity adresse_db = _mapper.Map <AdresseEntity>(_dto.Contact.Adresse); var _commande = await _service_commande.GetOneById(_dto.Id); _commande.Adresse = _dto.Contact.Adresse; await _service_commande.Validate(_commande); // verification pour CommandeFournisseur automatique var liste_commande_fournisseur_auto = await _service_commande_fournisseur.getCommandesFournisseurAuto(_commande); if (liste_commande_fournisseur_auto.Count > 0) { foreach (var item in liste_commande_fournisseur_auto) { item.NomCommandeFournisseurStatut = await _context.NomCommandeFournisseurStatutEntities.Where(o => o.Code == "T").FirstOrDefaultAsync(); await _service_commande_fournisseur.Add(item); } } return(RedirectToAction(nameof(Panier))); }