public IActionResult UpdateYachtTourPayment(YachtTourCharterUpdateModel model) { var result = _yachtTourService.UpdateYachtTourCharter(model); var response = new BaseResponse <bool>(); response = BaseResponse <bool> .Success(result); return(Ok(response)); }
public bool UpdateYachtTourCharter(YachtTourCharterUpdateModel model) { using (var trans = _yachtDbContext.Database.BeginTransaction()) { try { var tourCharter = _yachtDbContext.YachtTourCharters.AsNoTracking().Where(x => x.UniqueId == model.CharterUniqueId).FirstOrDefault(); if (tourCharter == null) { return(false); } tourCharter.StatusFid = model.StatusId; _yachtDbContext.YachtTourCharters.Update(tourCharter); _yachtDbContext.SaveChanges(); var tourCharterPaymentLog = _yachtDbContext.YachtTourCharterPaymentLogs.AsNoTracking().Where(x => x.TourCharterFid == tourCharter.Id).FirstOrDefault(); if (tourCharterPaymentLog == null) { return(false); } tourCharterPaymentLog.PaymentBy = model.CreatedUser; tourCharterPaymentLog.PaymentRef = model.TransactionId; tourCharterPaymentLog.StatusFid = model.StatusId; _yachtDbContext.YachtTourCharterPaymentLogs.Update(tourCharterPaymentLog); _yachtDbContext.SaveChanges(); trans.Commit(); trans.Dispose(); return(true); } catch { trans.Rollback(); trans.Dispose(); return(false); } } }