public Task <DataResult <DTOPaySlipBill> > GetPaySlipByIdAsync(int paySlipId) { return(Task.Run(() => { var paySlipDTO = new DTOPaySlipBill(); var paySlipEntity = paySlipBillRepository.GetById(paySlipId); if (paySlipEntity != null) { paySlipDTO = _mapper.Map <DTOPaySlipBill>(paySlipEntity); } return new DataResult <DTOPaySlipBill> { Errors = new List <ErrorDescriber>(), Target = paySlipDTO }; })); }
private DTOPaySlipBill CreateOrUpdatePaySlipBillBaseOnCondition(DTOPaySlipBill paySlipBillDTO, bool existedConditionToCheck) { var paySlipBillEntity = _mapper.Map <PaySlipBill>(paySlipBillDTO); if (existedConditionToCheck) { paySlipBillEntity.ModifiedDate = DateTime.Now; paySlipBillEntity = paySlipBillRepository.Update(paySlipBillEntity); } else { paySlipBillEntity.CreateDate = DateTime.Now; paySlipBillEntity = paySlipBillRepository.Insert(paySlipBillEntity); } _unitOfWork.SaveChanges(); return(_mapper.Map <DTOPaySlipBill>(paySlipBillEntity)); }
public Task <DataResult <DTOPaySlipBill> > CreateOrUpdatePaySlipBillAsync(DTOPaySlipBill paySlipBillDTO) { return(Task.Run(() => { var modifiedPaySlipBillDTO = new DTOPaySlipBill(); if (!string.IsNullOrEmpty(paySlipBillDTO.QuotationId)) { modifiedPaySlipBillDTO = CreateOrUpdatePaySlipBillBaseOnCondition(paySlipBillDTO, paySlipBillRepository.ExistByCondition(x => x.QuotationId == paySlipBillDTO.QuotationId)); } else { modifiedPaySlipBillDTO = CreateOrUpdatePaySlipBillBaseOnCondition(paySlipBillDTO, paySlipBillRepository.ExistByCondition(x => x.Id == paySlipBillDTO.Id)); } return new DataResult <DTOPaySlipBill> { Errors = new List <ErrorDescriber>(), Target = modifiedPaySlipBillDTO }; })); }
public async Task <IHttpActionResult> CreateOrUpdatePaySlip(int paySlipBillId, [FromBody] DTOPaySlipBill paySlipBillDTO) { return(await ExecuteServiceReturnDefaultResult(() => _serviceParameter.QuotationService.CreateOrUpdatePaySlipBillAsync(paySlipBillDTO), false)); }