public ActionResult Create(TaskViewModel TVM, int idProject) { if (!Request.IsAuthenticated) { return(RedirectToAction("Login", "Account")); } //redirect to nowhere if not admin if (!(User.IsInRole("Team Leader"))) { return(RedirectToAction("Nowhere", "Account")); } Tasks T = new Tasks(); Project P = PS.GetById(idProject); if (TVM.Start_Date >= P.Start_Date && TVM.End_Date <= P.End_Date && TVM.Start_Date >= DateTime.Now.Date) { T.TasksId = TVM.TasksId; T.TaskName = TVM.TaskName; T.Start_Date = TVM.Start_Date; T.End_Date = TVM.End_Date; T.Duration = (TVM.End_Date - TVM.Start_Date).TotalDays.ToString(); T.Status = Domain.Entities.status.Not; T.Description = TVM.Description; T.ProjectFK = idProject; TS.Add(T); TS.Commit(); return(RedirectToAction("Details", "Project", new { id = idProject })); } else { ViewBag.Message = "Tasks dates must be between " + P.Start_Date.ToString("dd/MM/yyyy") + " and " + P.End_Date.ToString("dd/MM/yyyy") + " and Start Date greater tha Today !!!"; return(View("Create")); } }
public ActionResult Create(TaskViewModel TVM, int idProject) { Tasks T = new Tasks(); T.TasksId = TVM.TasksId; T.TaskName = TVM.TaskName; T.Start_Date = TVM.Start_Date; T.End_Date = TVM.End_Date; T.Estimation = TVM.Estimation; T.Status = Domain.Entities.status.Done; T.Description = TVM.Description; T.Duration = TVM.Duration; T.ProjectFK = idProject; TS.Add(T); TS.Commit(); return(RedirectToAction("Details", "Project", new { id = idProject })); }