public IActionResult UpdateCredit([FromBody] UpdateCreditDto creditUpdate) { using (var db = new db()) { ServiceConstants constants = new ServiceConstants(); var credits = (from cred in db.credits where cred.UserId == creditUpdate.UserId && cred.Service == creditUpdate.Service select cred).ToList(); if (credits != null && credits.Count > 0) { Credit credit = credits.FirstOrDefault(); credit.ApplicationRef = creditUpdate.ApplicationRef; if (db.Update(credit) == 1) { if (creditUpdate.Service.Equals(constants.NAMESEARCH)) { var searchInfor = (from searchInfo in db.SearchInfo where searchInfo.SearchRef == creditUpdate.ApplicationRef select searchInfo).FirstOrDefault(); searchInfor.Payment = "Paid"; if (db.Update(searchInfor) == 1) { return(Ok(credit)); } } if (creditUpdate.Service.Equals(constants.PVTLIMITEDENTITY)) { var companyInfo = (from coInfo in db.CompanyInfo where coInfo.Application_Ref == creditUpdate.ApplicationRef select coInfo).FirstOrDefault(); companyInfo.Payment = "Paid"; if (db.Update(companyInfo) == 1) { return(Ok(credit)); } } } } } return(NotFound()); }
public async Task <bool> UpdateCreditAsync(UpdateCreditRequest request, int creditId) { var updateDto = new UpdateCreditDto { Id = creditId, BankAccountNumber = request.BankAccountNumber, BankName = request.BankName, ContractNumber = request.ContractNumber, CurrencyId = request.CurrencyId, Description = request.Description, InitialCreditValue = request.InitialCreditValue, InitNoOfPayments = request.InitNoOfPayments, Name = request.Name, }; var credit = _mapper.Map <Credit>(updateDto); return(await _baseRepository.UpdateEntityAsync(credit)); }