public async Task <IActionResult> TurnIn(FilesToAssignmentInputModel inputModel, int id) { ApplicationUser user = await this.userManager.GetUserAsync(this.User); inputModel.AssignmentId = id; inputModel.UserId = user.Id; await this.assignmentsService.TurnIn(inputModel); return(this.RedirectToAction("GetInfo", "Assignments", new { Id = id })); }
public async Task <int> TurnIn(FilesToAssignmentInputModel inputModel) { Assignment assignment = this.assignmentRepository.All().FirstOrDefault(a => a.Id == inputModel.AssignmentId); UserAssignment userAssignment = this.userAssignmentRepository .All() .FirstOrDefault(ua => ua.AssignmentId == inputModel.AssignmentId && ua.UserId == inputModel.UserId); userAssignment.TurnedOn = DateTime.UtcNow; if (inputModel.Files != null) { await this.AttachFile(assignment, inputModel.Files, FileType.Submit, inputModel.UserId); } await this.assignmentRepository.SaveChangesAsync(); await this.userAssignmentRepository.SaveChangesAsync(); return(assignment.Id); }