public async Task <IActionResult> EditAssignment(Guid AssignmentId, EditAssignmentViewModel model) { if (ModelState.IsValid) { Assignment assignment = await _assignmentService.GetAssignmentById(AssignmentId); AppUser currentUser = _userManager.GetUserAsync(User).Result; Guid TeamId = await _assignmentService.GetTeamByAssignmentId(AssignmentId); assignment.AssignmentName = model.AssignmentName; assignment.AssignmentDescription = model.AssignmentDescription; assignment.AssignmentStatus = model.AssignmentStatus; if (model.AssignmentStatus == CompletionStatus.Done) { assignment.CompletedTime = DateTime.Now; } await _assignmentService.EditAssignment(assignment); if (await _userManager.IsInRoleAsync(currentUser, "Manager")) { return(RedirectToAction("GetTeamAssignmentList", "Assignment", new { TeamId })); } return(RedirectToAction("GetAllAssignments")); } return(View(model)); }
public async Task <IActionResult> EditAssignment([FromBody] AssignmentRequest request) { Assignment temp = _mapper.Map <Assignment>(request); if (await _assignmentService.EditAssignment(temp)) { return(Ok("Successful")); } return(BadRequest("Assignment Is Exist")); }
public void Put(int id, [FromBody] AssignmentViewModel data) { if (data.DueDate < DateTime.Now) { throw new Exception("Wrong date input, date must match format yyyy-MM-dd"); } assignmentService.EditAssignment(new AssignmentModel { Id = id, Laboratory = new LaboratoryModel { Id = data.LaboratoryId }, Name = data.Name, DueDate = data.DueDate, Description = data.Description }); }
public IActionResult EditAssignment([FromBody] MvAssignment assignment) { try { dynamic jsonString = _assignmentService.EditAssignment(assignment); return(Ok(jsonString)); } catch (Exception e) { throw e; } }
public IActionResult EditAssignment(int?courseId, [Bind("Title, Subject, Description, DueToDate")] Assignment assignment) { if (courseId == null || courseId == 0) { return(NotFound()); } if (ModelState.IsValid) { var boolean = _assignmentDB.EditAssignment(assignment); if (boolean) { return(RedirectToAction(nameof(Details), "Course", new { id = courseId })); } } return(BadRequest()); }