// GET: Project/Create public ActionResult Create() { var c = Us.GetAll(); List <WebApplication1.Models.Entities.User> vm = new List <WebApplication1.Models.Entities.User>(); foreach (var item in c) { WebApplication1.Models.Entities.User Cvm = new WebApplication1.Models.Entities.User(); if (item.RoleUser == "TeamLeader") { Cvm.Id = item.Id; Cvm.Email = item.Email; vm.Add(Cvm); } } ViewBag.cat = new SelectList(vm, "Id", "Email"); var C = Cs.GetAll(); foreach (var item in C) { CategoryViewModel Cvm = new CategoryViewModel(); Cvm.categoryId = item.categoryId; } ViewBag.cate = new SelectList(C, "categoryId", "categoryname"); return(View()); }
public ActionResult Create(ProjectViewModel pvm, WebApplication1.Models.Entities.User uvm, CategoryViewModel categ) { //var c = Cs.GetAll(); //foreach (var item in c) //{ // CategoryViewModel Cvm = new CategoryViewModel(); // Cvm.categoryname = item.categoryname; // Cvm.categoryId = item.categoryId; //} var C = Cs.GetAll(); foreach (var item in C) { CategoryViewModel Cvm = new CategoryViewModel(); Cvm.categoryId = item.categoryId; } ViewBag.cate = new SelectList(C, "categoryId", "categoryname"); //ViewBag.cat = new SelectList(c, "categoryId", "categoryname"); var c = Us.GetAll(); foreach (var item in c) { if (item.RoleUser == "TeamLeader") { WebApplication1.Models.Entities.User Cvm = new WebApplication1.Models.Entities.User(); //Cvm.categoryId = item.categoryId; Cvm.Id = item.Id; } } ViewBag.cat = new SelectList(c, "Id", "Email"); Project p = new Project(); p.projectId = pvm.projectId; p.categoryId = categ.categoryId; p.projectname = pvm.projectname; p.description = pvm.description; p.plan = pvm.plan; p.goals = pvm.goals; p.DateDebut = DateTime.Now; p.state = (Domain.Entities.stat)stat.To_Do; p.team_leaderId = uvm.Id; //p.ListTask = (ICollection<Domain.Entities.Task>)pvm.ListTask; Ps.Add(p); Ps.Commit(); try { // TODO: Add insert logic here return(RedirectToAction("Index")); } catch { return(View()); } }