public async Task <NonBillableProductsDTO> GetNonBillableProduct(int id) { NonBillableProducts dbRecord = await _unitOfWork.NonBillableProductsRepository.GetById(id); NonBillableProductsDTO result = _mapper.Map <NonBillableProductsDTO>(dbRecord); return(result); }
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); }