public IActionResult SaveAttendance(int StudentID, string Value, string HoursTotal, int SubjectID, DateTime date) { Subject localSubject = subjectRepository.Subjects.FirstOrDefault(s => s.SubjectID == SubjectID); var students = studentRepository.Students; var studentsSubjects = studentsSubjectsRepository.StudentsSubjects; var protocols = protocolRepository.Protocols; TempData["HoursTotal"] = HoursTotal; protocolRepository.AddProtocol(StudentID, Value, HoursTotal, SubjectID, date); return(View("RegisterAttendance", new ProtocolsListViewModel { Students = students, Subject = localSubject, StudentsSubjects = studentsSubjects, Protocols = protocols, Date = date })); }
public async Task <ActionResult <ProtocolDto> > CreateProtocol(ProtocolDto protocolDto) { var username = User.GetUsername(); var protocol = new Protocol { CreatorUsername = username, CreatorId = User.GetUserId(), ProtocolName = protocolDto.ProtocolName }; _protocolRepository.AddProtocol(protocol); if (await _protocolRepository.SaveAllAsync()) { return(Ok(_mapper.Map <ProtocolDto>(protocol))); } return(BadRequest("Failed to create protocol")); }