public ActionResult Create(AssignTask assignTask) { var task = TaskBO.GetById(assignTask.TaskId); if (task == null) { return(RedirectToAction("NotFound", "Home")); } assignTask.CreateBy = CurrentUser.Id; assignTask.CreateDate = DateTime.Now; assignTask.ModifyBy = CurrentUser.Id; assignTask.ModifyDate = DateTime.Now; if (!string.IsNullOrEmpty(assignTask.StartAndEndDate) && assignTask.StartAndEndDate.Split('-').Length == 2) { var strStart = assignTask.StartAndEndDate.Split('-')[0].Trim(); var strEnd = assignTask.StartAndEndDate.Split('-')[1].Trim(); DateTime sdate; DateTime edate; if (DateTime.TryParseExact(strStart, Helper.FormatDate, new CultureInfo("en-US"), DateTimeStyles.None, out sdate)) { assignTask.StartDate = sdate; } if (DateTime.TryParseExact(strEnd, Helper.FormatDate, new CultureInfo("en-US"), DateTimeStyles.None, out edate)) { assignTask.EndDate = edate; } TaskBO.AssignTaskInsert(assignTask); AlertBO.Insert(assignTask.Requirement, (int)AlertType.AssignTask, 0, assignTask.UserId); } return(RedirectToAction("Index", new { id = assignTask.TaskId })); ViewBag.Task = task; ViewBag.Users = UserBO.GetByDepartmentId(CurrentUser.DepartmentLeader); return(View(assignTask)); }