public int Add(DTOCourse dtoCourse) { Course entytiCourse = CourseMapper.GetEntityCourse(dtoCourse); UnitOfWork.CourseRepository.Add(entytiCourse); UnitOfWork.Commit(); return(entytiCourse.Id); }
public int Edit(DTOCourse dtoCourse) { Course entityCourse = CourseMapper.GetEntityCourse(dtoCourse); UnitOfWork.CourseRepository.Update(entityCourse); UnitOfWork.Commit(); return(entityCourse.Id); }
public static Course GetEntityCourse(DTOCourse dtoCourse) { Course entityCourse = new Course() { Description = dtoCourse.Description, EndDate = dtoCourse.EndDate, Id = dtoCourse.Id, IdReferent = dtoCourse.IdReferent, StartDate = dtoCourse.StartDate, ReferenceYear = dtoCourse.ReferenceYear }; return(entityCourse); }
public IActionResult Edit([FromBody] DTOCourse dtoCourse) { try { _logger.LogInformation("Request Courses/Add"); return(Ok(courseManager.Edit(dtoCourse))); } catch (Exception ex) { _logger.LogError("Error during Courses/Add", ex.Message); courseManager.Dispose(); return(StatusCode(500, ex.Message)); } }
public static DTOCourse GetDTOCourse(Course entityCourse) { DTOCourse dtoCourse = new DTOCourse() { Description = entityCourse.Description, EndDate = entityCourse.EndDate, Id = entityCourse.Id, IdReferent = entityCourse.IdReferent, Lessons = (from lesson in entityCourse.Lessons select LessonMapper.GetDTOLesson(lesson)).ToList(), StartDate = entityCourse.StartDate, Referent = $"{entityCourse.IdReferentNavigation.Name} {entityCourse.IdReferentNavigation.LastName}", ReferenceYear = entityCourse.ReferenceYear }; return(dtoCourse); }