public async Task <IActionResult> Submit([FromForm] SubmitAssignmentDtoForAdd model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _response = await _repo.SubmitAssignment(model); return(Ok(_response)); }
public async Task <ServiceResponse <object> > SubmitAssignment(SubmitAssignmentDtoForAdd model) { var objToCreate = new ClassSectionAssigmentSubmission { ClassSectionAssignmentId = model.AssignmentId, Description = model.Description, StudentId = _LoggedIn_UserID, CreatedDatetime = DateTime.UtcNow, }; if (model.files != null && model.files.Count() > 0) { for (int i = 0; i < model.files.Count(); i++) { var dbPath = _filesRepository.SaveFile(model.files[i]); if (string.IsNullOrEmpty(objToCreate.SubmittedMaterial)) { objToCreate.SubmittedMaterial = objToCreate.SubmittedMaterial + dbPath; } else { objToCreate.SubmittedMaterial = objToCreate.SubmittedMaterial + "||" + dbPath; } } } await _context.ClassSectionAssigmentSubmissions.AddAsync(objToCreate); await _context.SaveChangesAsync(); var toCreateTrans = new StudentActivityTransaction { StudentId = _LoggedIn_UserID, Value = _LoggedIn_UserName + " you submit an assignment at " + DateFormat.ToDateTime(DateTime.UtcNow), Details = "", UpdatedDateTime = DateTime.UtcNow }; await _context.StudentActivityTransactions.AddAsync(toCreateTrans); await _context.SaveChangesAsync(); _serviceResponse.Success = true; _serviceResponse.Message = CustomMessage.Added; return(_serviceResponse); }