public async Task <bool> Delete(int id) { try { var model = await _dbContext.Payments.Include(x => x.Deb).SingleAsync(x => x.Id == id); if (model != null) { Debs deb = _deb.Get(model.Deb.Id); if (deb.Money >= model.Quantity) { deb.Money += model.Quantity; model.Deleted = Model.Enums.Deleted.yes; _deb.Update(deb); } else { model.Deleted = Model.Enums.Deleted.yes; _deb.Update(deb); } _dbContext.Entry(model).State = EntityState.Modified; await _dbContext.SaveChangesAsync(); return(true); } return(false); } catch (Exception) { return(false); } }
public ActionResult Add(Debs model) { model.DateTime = _dateTime; if (ModelState.IsValid) { _repository.Add(model); Alerts.Type = 10; } else { Alerts.Type = 13; } return(RedirectToAction("Detail", "AccountClient", new { id = model.AccountId })); }
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 bool Update(Debs entity) { try { var model = _dbContext.Debs.Single(x => x.Id == entity.Id); model.Money = entity.Money; model.Description = entity.Description; _dbContext.Entry(model).State = EntityState.Modified; _dbContext.SaveChanges(); return(true); } catch (Exception) { return(false); } }
public ActionResult Add(Debs model) { model.DateTime = DateTime.Now; if (ModelState.IsValid) { if (_repository.Add(model)) { TempData["response"] = "Agregado correctamente"; TempData["icon"] = "success"; return(RedirectToAction("Detail", "AccountClient", new { id = model.AccountId })); } } TempData["response"] = "Lo sentimos!, ha ocurrido un error"; TempData["icon"] = "error"; return(RedirectToAction("Detail", "AccountClient", new { id = model.AccountId })); }
public bool Add(Debs entity) { try { _dbContext.Debs.Add(entity); var account = _dbContext.Accounts .Single(x => x.Id == entity.AccountId); account.Total += entity.Money; _Account.Update(account); _dbContext.SaveChanges(); return(true); } catch (Exception) { return(false); throw; } }
public async Task <bool> Update(Payment entity) { try { var model = await _dbContext.Payments.Include(x => x.Deb).SingleAsync(x => x.Id == entity.Id); Debs deb = _deb.Get(model.Deb.Id); deb.Money -= (entity.Quantity - model.Quantity); if (_deb.Update(deb)) { model.Quantity = entity.Quantity; _dbContext.Entry(model).State = EntityState.Modified; await _dbContext.SaveChangesAsync(); return(true); } return(false); } catch (Exception) { return(false); } }
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)); } }