public ActionResult Delete(int id) { RechargingCouponService s = new RechargingCouponService(); recharging_coupon c = s.GetById(id); if (c == null) { return(new HttpNotFoundResult()); } s.Delete(s.GetById(id)); s.Commit(); return(RedirectToAction("Index")); }
public ActionResult Pay(string code) { RechargingCouponService s = new RechargingCouponService(); recharging_coupon c = s.getByCode(code); System.Diagnostics.Debug.WriteLine(code); if (c != null) { if (c.isUsed) { ViewBag.Code = 1; ViewBag.Message = "The coupon is used !"; } else { user u = (user)Session["user"]; if (u != null) { c.isUsed = true; s.Update(c); s.Commit(); UserService us = new UserService(); System.Diagnostics.Debug.WriteLine(code); u = us.GetById(u.id); u.balance += (double)c.amount; us.Update(u); us.Commit(); ViewBag.Code = 0; ViewBag.Message = "Balance recharged !"; } } } else { ViewBag.Code = 1; ViewBag.Message = "The coupon is not valid !"; } if (ViewBag.code != 0) { return(RedirectToAction("Recharge", new { message = ViewBag.Message })); } return(RedirectToAction("Index", "Home")); }