/// <summary> /// Редактирование задачи /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void EditTaskBtn_OnClick(object sender, RoutedEventArgs e) { PopupBox.IsPopupOpen = false; MainWindow.ShowWrap(sender, new RoutedEventArgs()); var taskEdit = new TaskEdit(_task); taskEdit.ShowInTaskbar = false; taskEdit.IsOpen = true; }
public ActionResult Edit(int id) { var service = CreateTaskService(); var detail = service.GetTaskById(id); var model = new TaskEdit { TaskId = detail.TaskId, TaskName = detail.TaskName, TaskSummary = detail.TaskSummary, DueDate = detail.DueDate, Flagged = detail.Flagged, Completed = detail.Completed, }; return(View(model)); }
public bool UpdateTask(TaskEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Tasks .Single(e => e.TaskId == model.TaskId && e.TaskOwnerId == _userId); entity.TaskName = model.TaskName; entity.TaskSummary = model.TaskSummary; entity.DueDate = model.DueDate; entity.Flagged = model.Flagged; entity.Completed = model.Completed; return(ctx.SaveChanges() == 1); } }
public ActionResult Edit(int id, TaskEdit model) { if (!ModelState.IsValid) { return(View(model)); } if (model.TaskId != id) { ModelState.AddModelError("", "Id Mismatch"); return(View(model)); } var service = CreateTaskService(); if (service.UpdateTask(model)) { TempData["SaveResult"] = "Your task was updated!"; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Your note could not be updated!"); return(View(model)); }
public async Task <ResponseEntity> updateTask(TaskEdit model, string token) { UserJira user = _userService.getUserByToken(token).Result; Project pro = _projectRepository.GetSingleByConditionAsync("id", model.projectId).Result; Repository.Models.Task taskModel = _taskRepository.GetSingleByConditionAsync("taskId", model.taskId).Result; if (taskModel == null) { return(new ResponseEntity(StatusCodeConstants.NOT_FOUND, "Task is not found!", MessageConstants.MESSAGE_ERROR_404)); } if (pro == null) { return(new ResponseEntity(StatusCodeConstants.NOT_FOUND, "Project is not found!", MessageConstants.MESSAGE_ERROR_404)); } if (pro.creator != user.id) { return(new ResponseEntity(StatusCodeConstants.FORBIDDEN, "User is unthorization!", MessageConstants.MESSAGE_ERROR_403)); } string alias = FuncUtilities.BestLower(model.taskName); //Kiểm tra task tồn tại chưa var taskValid = _taskRepository.GetSingleByConditionAsync("alias", alias).Result; if (taskValid.taskId != taskModel.taskId) { return(new ResponseEntity(StatusCodeConstants.ERROR_SERVER, "Task name already exists!", MessageConstants.MESSAGE_ERROR_500)); } taskModel.taskName = model.taskName; taskModel.alias = FuncUtilities.BestLower(model.taskName); taskModel.description = FuncUtilities.Base64Encode(model.description); taskModel.statusId = model.statusId; taskModel.originalEstimate = model.originalEstimate; taskModel.timeTrackingSpent = model.timeTrackingSpent; taskModel.timeTrackingRemaining = model.timeTrackingRemaining; taskModel.projectId = model.projectId; taskModel.typeId = model.typeId; taskModel.reporterId = user.id; taskModel.priorityId = model.priorityId; taskModel.deleted = false; await _taskRepository.UpdateAsync("taskId", taskModel.taskId, taskModel); //dell user cũ var taskUserCu = _taskUserRepository.GetMultiByConditionAsync("taskId", taskModel.taskId).Result; if (taskUserCu.Count() > 0) { List <dynamic> lstDynamicId = new List <dynamic>(); foreach (var item in taskUserCu) { lstDynamicId.Add(item.id); } await _taskUserRepository.DeleteByIdAsync(lstDynamicId); } foreach (var item in model.listUserAsign) { Task_User tu = new Task_User(); tu.taskId = taskModel.taskId; tu.deleted = false; tu.userId = item; await _taskUserRepository.InsertAsync(tu); } return(new ResponseEntity(StatusCodeConstants.OK, taskModel, "update task successfully!")); }
public async Task <IActionResult> updateTask(TaskEdit model) { var accessToken = Request.Headers[HeaderNames.Authorization]; return(await _projectService.updateTask(model, accessToken)); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void EditButton_Click(object sender, RoutedEventArgs e) { TaskEdit?.Invoke(this, TaskInfo); }