public async Task <bool> Add(Payment entity) { try { var deb = await _dbContext.Debs.SingleAsync(x => x.Id == entity.DebId); if (deb.Money >= entity.Quantity) { deb.Money -= entity.Quantity; _deb.Update(deb); _dbContext.Payments.Add(entity); await _dbContext.SaveChangesAsync(); return(true); } return(false); } catch (Exception) { return(false); } }
public ActionResult Update(Debs debs) { if (debs.Money > 0) { if (_repository.Update(debs)) { TempData["response"] = "Actualizado correctamente"; TempData["icon"] = "success"; return(RedirectToAction("Detail", "AccountClient", new { id = debs.AccountId })); } } TempData["response"] = "Lo sentimos, ha ocurrido un error"; TempData["icon"] = "error"; return(RedirectToAction("Detail", "AccountClient", new { id = debs.AccountId })); }
public ActionResult Update(Debs debs) { if (debs.Money != 0) { var model = _repository.Update(debs); if (model) { Alerts.Type = 11; return(RedirectToAction("Detail", "AccountClient", new { id = debs.AccountId })); } else { Alerts.Type = 13; return(View(debs)); } } else { Alerts.Type = 13; ViewBag.Response = Alerts.Type; Alerts.Type = 0; return(View(debs)); } }