public ActionResult Create(TasksViewModel tvm, ProjectViewModel pvm, WebApplication1.Models.Entities.User uvm, DifficulteViewModel d) { var p = Ps.GetAll(); foreach (var item in p) { ProjectViewModel Pvm = new ProjectViewModel(); Pvm.projectId = item.projectId; Pvm.projectname = item.projectname; Pvm.categoryId = item.categoryId; Pvm.description = item.description; Pvm.plan = item.plan; Pvm.goals = item.goals; Pvm.state = (WebApplication1.Models.stat)stat.To_Do; } ViewBag.pro = new SelectList(p, "projectId", "projectname"); var u = Us.GetAll(); foreach (var item in u) { Models.Entities.User Uvm = new Models.Entities.User(); Uvm.Id = item.Id; } ViewBag.usr = new SelectList(u, "Id", "Id"); var D = Ds.GetAll(); foreach (var item in D) { DifficulteViewModel df = new DifficulteViewModel(); df.DifficulteId = item.DifficulteId; } ViewBag.diff = new SelectList(D, "DifficulteId", "DifficulteId"); Tasks t = new Tasks(); t.tasksId = tvm.taskId; t.projectId = pvm.projectId; t.team_memberId = uvm.Id; // p.deadline = pvm.deadline; //t.duration = tvm.duration; //t.state = (Domain.Entities.stat)stat.To_Do; t.DifficulteId = d.DifficulteId; t.nomtask = tvm.nomtask; Ts.Add(t); Ts.Commit(); try { // TODO: Add insert logic here return(RedirectToAction("Index")); } catch { return(View()); } }