private void MapAndSaveCourse(CourseFormViewModel model) { var dto = new CourseFormDto { CountryCode = model.CountryCode, HolesTotal = model.HolesTotal, NumberOfHoles = model.NumberOfHoles, Latitude = model.Latitude, Longitude = model.Longitude, ApiParentID = model.ApiParentID, ApiID = model.ApiID, CourseID = model.CourseID, Area = model.Area, TotalDistance = model.TotalDistance, TotalParValue = model.TotalParValue, Main = model.Main, FullName = model.FullName, Name = model.Name, Holes = _mapper.Map <List <CourseHolesDto> >(model.Holes), }; dto.CreateHoles.CourseID = model.CreateHoles.CourseID; dto.CreateHoles.NumberOfHoles = model.CreateHoles.NumberOfHoles; dto.CreateHoles.Holes = _mapper.Map <List <HoleDto> >(model.CreateHoles.Holes); _adminService.SaveUpdatedCourse(dto); }
public void SaveUpdatedCourse(CourseFormDto model) { var course = _mapper.Map(model, _unitOfWork.Courses.FindById(model.CourseID)); course.Holes = _mapper.Map(model.Holes, _unitOfWork.Holes.FindAllBy(x => x.CourseID == model.CourseID)); _unitOfWork.Courses.Edit(course); _unitOfWork.Complete(); }