예제 #1
0
        public async Task <int> Add(AccountTypeToSaveDto Entity)
        {
            if (await _unitOfWork.AccountType.Exists(x => x.Description == Entity.Description))
            {
                throw new Exception("Name already exists.");
            }

            AccountType entity = _mapper.Map <AccountType>(Entity);

            _unitOfWork.AccountType.Add(entity);

            _unitOfWork.Complete();

            return(entity.Id);
        }
예제 #2
0
        public async Task <bool> Add(AccountTypeToSaveDto Entity)
        {
            if (await _unitOfWork.AccountType.AccountTypeExists(Entity.Description))
            {
                throw new Exception("Name already exists.");
            }

            AccountType entity = _mapper.Map <AccountType>(Entity);

            _unitOfWork.AccountType.Add(entity);

            if (_unitOfWork.Complete() > 0)
            {
                return(true);
            }

            return(false);
        }
 public async Task <IActionResult> Post(AccountTypeToSaveDto AccountTypeDto)
 {
     try
     {
         if (await _serviceManager.AccountType.Add(AccountTypeDto))
         {
             return(StatusCode(201));
         }
         else
         {
             return(BadRequest());
         }
     }
     catch (System.Exception e)
     {
         return(HandleException(e));
     }
 }