public LecturesDateControllerTests() { _mockRepo = new Mock <IRepositoryService <LectureDate> >(); lecturesDateController = new LecturesDateController(_mockRepo.Object); GuidId = Guid.Parse(Id); LectureDate = new LectureDate { Id = Guid.Parse(Id) }; }
public async Task <ActionResult <LectureDate> > UpdateLectureDate(LectureDate lectureDate) { try { var lectureDateToUpdate = await repositoryService.GetSingle(lectureDate.Id); if (lectureDateToUpdate == null) { return(NotFound($"LectureDate with Id = {lectureDate.Id} not found")); } return(await repositoryService.Update(lectureDate)); } catch (Exception) { return(StatusCode(StatusCodes.Status500InternalServerError, "Error updating data from the database")); } }
public async Task <ActionResult <LectureDate> > CreateLectureDate(LectureDate lectureDate) { try { if (lectureDate == null) { return(BadRequest()); } var createdLectureDate = await repositoryService.Add(lectureDate); return(CreatedAtAction(nameof(GetLectureDate), new { id = lectureDate.Id }, lectureDate)); } catch (Exception) { return(StatusCode(StatusCodes.Status500InternalServerError, "Error creating data from the database")); } }