public async Task <IActionResult> AddNewTask(PreTaskModel taskModel) { if ((taskModel.StartDate < DateTime.Now) || (taskModel.EndDate < DateTime.Now)) { return(RedirectToAction(nameof(AddNewTask), new { currentContext = true })); } if (taskModel.StartDate >= taskModel.EndDate) { return(RedirectToAction(nameof(AddNewTask), new { invalid = true })); } if (ModelState.IsValid) { int id = await _taskRepository.AddNewTask(taskModel); if (id > 0) { return(RedirectToAction(nameof(AddNewTask), new { isSuccess = true, taskId = id })); } } ViewBag.project = new SelectList(await _projectRepository.GetProjects(), "ID", "Title"); return(View()); }
public async Task <IActionResult> EditTasks(PreTaskModel task) { if (ModelState.IsValid) { bool Success = await _taskRepository.EditTasks(task); if (Success == true) { return(RedirectToAction(nameof(GetAllTasks), new { Success = true })); } } var data = await _taskRepository.GetTaskById(0); ViewData["task"] = data; return(View(data)); }
//edit task part public async Task <bool> EditTasks(PreTaskModel task) { var tas = await _context.PreSalesTasks.FindAsync(task.Id); tas.Description = task.Description; tas.Number = task.Number; tas.Duration = task.Duration; tas.StartDate = task.StartDate; tas.EndDate = task.EndDate; tas.Priority = task.Priority; tas.Assignee = task.Assignee; tas.ProjectsID = task.ProjectsID; _context.Entry(tas).State = EntityState.Modified; await _context.SaveChangesAsync(); return(true); }
public async Task <ViewResult> AddNewTask(int projectId, bool isSuccess = false, int taskId = 0, bool currentContext = false, bool invalid = false) { ViewBag.projects = new SelectList(await _projectRepository.GetProjects(), "ID", "Title"); ViewBag.project = await _projectRepository.GetProjectByID(projectId); var model = new PreTaskModel() { ProjectsID = projectId }; ViewBag.IsSuccess = isSuccess; ViewBag.TaskId = taskId; ViewBag.invalid = invalid; ViewBag.context = currentContext; return(View(model)); }
public async Task <int> AddNewTask(PreTaskModel model) { var newTask = new PreSalesTasks() { Number = model.Number, Description = model.Description, Duration = model.Duration, StartDate = model.StartDate, EndDate = model.EndDate, Priority = model.Priority, Assignee = model.Assignee, ProjectsID = model.ProjectsID, IsAssigned = false }; await _context.PreSalesTasks.AddAsync(newTask); await _context.SaveChangesAsync(); return(newTask.Id); }