public ActionResult affecte(int id_marche) {// reepet de delais List <ParticipationRequest> listeoffre = new List <ParticipationRequest>(); ParticipationRequest pr; Marché mar = dbmetier.Marché.Where(a => a.id_marché == id_marche).FirstOrDefault(); List <Participation> listparticipation = dbmetier.Participations.Where(a => a.id_marché_participation == mar.id_marché && a.budget_prestation != null).ToList(); foreach (Participation item in listparticipation) { List <Profil_cout_chargeVM> listPCVM = new List <Profil_cout_chargeVM>(); Profil_cout_chargeVM element; prestataire prestataire = dbmetier.prestataires.Where(a => a.id_prestataire == item.id_prestataire_participation).FirstOrDefault(); List <Participation_profil> listepp = dbmetier.Participation_profil.Where(a => a.id_participation_fk == item.id_participation).ToList(); foreach (var item2 in listepp) { element = new Profil_cout_chargeVM(); element.cout = (int)item2.cout_unit_ht; element.libelle = item2.Profil.libelle_profil; listPCVM.Add(element); } pr = new ParticipationRequest { prestataire_participant = prestataire, budget_prestation = (int)item.budget_prestation, listeprofil_cout = listPCVM, }; listeoffre.Add(pr); } ViewBag.id_marche = id_marche; return(View(listeoffre)); }
public ActionResult Create(prestataire pres) { // TODO: Add insert logic here if (ModelState.IsValid) { dbmetier.prestataires.Add(pres); dbmetier.SaveChanges(); return(RedirectToAction("Index")); } return(View(pres)); }
public ActionResult Modifier_image_profil(HttpPostedFileBase file) { if (file != null) { prestataire pre = dbmetier.prestataires.Find(User.Identity.GetUserId()); //get the bytes from the uploaded file byte[] data = GetBytesFromFile(file); pre.image_prestataire = data; dbmetier.SaveChanges(); } return(RedirectToAction("Information_prstataire", "Prestataire")); }
public async Task <ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { var user = new ApplicationUser { UserName = model.UserName, Email = model.Email }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { // await SignInManager.SignInAsync(user, isPersistent:false, rememberBrowser:false); await this.UserManager.AddToRoleAsync(user.Id, model.Roles); dbmetier = new market_appEntities(); if (model.Roles == "prestataire") { prestataire pres = new prestataire(); pres.libelle = model.libelle; pres.raison_social = model.Raison_social; pres.id_prestataire_user = user.Id; pres.id_prestataire = user.Id; dbmetier.prestataires.Add(pres); dbmetier.SaveChanges(); } if (model.Roles == "responsable_marche") { Responsable_marché res = new Responsable_marché(); res.nom = model.Nom; res.prenom = model.Prenom; res.id_responsable_user = user.Id; res.id_responsable = user.Id; dbmetier.Responsable_marché.Add(res); dbmetier.SaveChanges(); } return(RedirectToAction("Register", "Account")); } ViewBag.Roles = new SelectList(db.Roles.ToList(), "Name", "Name"); AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }