public async Task <NonBillableProductsDTO> GetNonBillableProduct(int id) { NonBillableProducts dbRecord = await _unitOfWork.NonBillableProductsRepository.GetById(id); NonBillableProductsDTO result = _mapper.Map <NonBillableProductsDTO>(dbRecord); return(result); }
public async Task <IActionResult> Put(NonBillableProductsDTO NonBillableProducts) { var isUpdated = await _nonBillableProductsService.UpdateNonBillableProduct(NonBillableProducts); var response = new ApiResponse <bool>(isUpdated); return(Ok(response)); }
public async Task <IActionResult> GetNonBillableProducts(int id) { NonBillableProductsDTO NonBillableProducts = await _nonBillableProductsService.GetNonBillableProduct(id); var response = new ApiResponse <NonBillableProductsDTO>(NonBillableProducts); return(Ok(response)); }
private async Task CheckExistingCode(NonBillableProductsDTO newNonBillableProduct, int oldID = 0) { NonBillableProducts existingRecord = await _unitOfWork.NonBillableProductsRepository.GetByCode(newNonBillableProduct.Code, oldID); if (existingRecord != null) { throw new ValidationException("El código ingresado ya existe. Ingrese un código nuevo."); } }
public async Task InsertNonBillableProduct(NonBillableProductsDTO newNonBillableProduct) { await CheckExistingCode(newNonBillableProduct); NonBillableProducts dbRecord = _mapper.Map <NonBillableProducts>(newNonBillableProduct); await _unitOfWork.NonBillableProductsRepository.Add(dbRecord); await _unitOfWork.SaveAdministrationSwitchChangesAsync(); }
public async Task <bool> UpdateNonBillableProduct(NonBillableProductsDTO updatedNonBillableProductDTO) { NonBillableProducts existingRecord = await _unitOfWork.NonBillableProductsRepository.GetById(updatedNonBillableProductDTO.Id); if (existingRecord == null) { throw new ValidationException("Registro no existe para el ID proporcionado."); } await CheckExistingCode(updatedNonBillableProductDTO, existingRecord.IDNonBillableProducts); var updatedRecord = _mapper.Map <NonBillableProducts>(updatedNonBillableProductDTO); _unitOfWork.NonBillableProductsRepository.Update(existingRecord, updatedRecord); await _unitOfWork.SaveAdministrationSwitchChangesAsync(); return(true); }
public async Task <IActionResult> Post(NonBillableProductsDTO NonBillableProducts) { await _nonBillableProductsService.InsertNonBillableProduct(NonBillableProducts); return(Ok()); }