public UpdateLectureResultDTO UpdateLecture(UpdateLectureDTO lecture) { var updateResult = new UpdateLectureResultDTO { Updated = false, Lecture = null }; var lectureEntity = _repository.GetLectureByID(lecture.LectureId); //TODO: zrobić ładniejszy kod lectureEntity.Name = lecture.Name; lectureEntity.EcstsPoints = lecture.EcstsPoints; lectureEntity.MinimalSemester = lecture.MinimalSemester; lectureEntity.Description = lecture.Description; lectureEntity.Bibliography = lecture.Bibliography; lectureEntity.TeacherId = lecture.TeacherId; lectureEntity.Teacher = _teacherRepository.GetTeacherByID(lectureEntity.TeacherId); updateResult.Lecture = Mapper.Map <GetLectureDTO>(lectureEntity); _repository.UpdateLecture(lectureEntity); if (_repository.Save()) { updateResult.Updated = true; return(updateResult); } return(updateResult); }
public IHttpActionResult PutLecture(int id, UpdateLectureDTO lecture) { var updateResult = LectureService.UpdateLecture(lecture); if (updateResult.Updated) { return(Ok(updateResult)); } return(StatusCode(HttpStatusCode.NoContent)); }