コード例 #1
0
        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();
        }
コード例 #2
0
 public IHttpActionResult AddWorkType(AddWorkTypeDto dto)
 {
     return(CallBusinessLogicAction(() => _manager.AddWorkType(dto, User.Identity.GetUserId())));
 }