public void AddWorkType(AddWorkTypeDto dto, string currentUserId) { UserManager.IsUserInAdministrationRole(currentUserId); var repository = UnitOfWork.Repository <IWorkClassRepository>(); var workClass = repository.Get(dto.WorkClassId); if (workClass == null) { throw new BusinessFaultException(BusinessLogicExceptionResources.WorkClassNotFound); } var workType = workClass.WorkTypes.SingleOrDefault(w => !w.IsDeleted && w.Name == dto.Name); if (workType != null) { throw new BusinessFaultException(BusinessLogicExceptionResources.WorkTypeAlreadyContains); } workType = Mapper.Map <WorkType>(dto); workClass.WorkTypes.Add(workType); repository.Update(workClass); UnitOfWork.SaveChanges(); }
public IHttpActionResult AddWorkType(AddWorkTypeDto dto) { return(CallBusinessLogicAction(() => _manager.AddWorkType(dto, User.Identity.GetUserId()))); }