public void AddCarModel(AddCarModelDto dto, string currentUserId) { UserManager.IsUserInAdministrationRole(currentUserId); var repository = UnitOfWork.Repository <ICarMarksRepository>(); var mark = repository.Get(dto.MarkId); if (mark == null) { throw new BusinessFaultException(BusinessLogicExceptionResources.CarMarkNotFound); } var model = mark.Models.SingleOrDefault(m => !m.IsDeleted && m.Name == dto.Name); if (model != null) { throw new BusinessFaultException(BusinessLogicExceptionResources.CarModelAlreadyContains); } model = Mapper.Map <CarModel>(dto); mark.Models.Add(model); repository.Update(mark); UnitOfWork.SaveChanges(); }
public IHttpActionResult AddCarModel(AddCarModelDto dto) { return(CallBusinessLogicAction(() => _manager.AddCarModel(dto, User.Identity.GetUserId()))); }