// GET: /Users/ public ActionResult Index(int isdelete = 0, int restoreid = 0) { var list = (dynamic)null; TempData["restore"] = ""; if (isdelete == 0) { if (restoreid > 0) { if (db.tblDiscount.Any(a => a.DiscountID == restoreid && a.IsDelete == true)) { tblDiscount tbldiscount = db.tblDiscount.Find(restoreid); tbldiscount.IsDelete = false; db.Entry(tbldiscount).State = EntityState.Modified; db.SaveChanges(); TempData["msg"] = "Record Restore Successfully"; // return View("Index","User"); } } list = db.tblDiscount.Where(a => a.IsDelete != true).OrderByDescending(a => a.DiscountID).ToList(); } else { TempData["restore"] = "restore"; list = db.tblDiscount.Where(a => a.IsDelete == true).OrderByDescending(a => a.DiscountID).ToList(); } return(View(list)); }
public ActionResult DeleteConfirmed(int id) { tblDiscount tbldiscount = db.tblDiscount.Find(id); db.tblDiscount.Remove(tbldiscount); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create([Bind(Include = "DiscountID,DiscountCode,DiscountType,DiscountName,DiscountAmount,CreatedBy,UpdatedBy,CreateDate,UpdateDate,IsDelete,IsActive,SchoolID,DeleteBy,DeleteDate")] tblDiscount tbldiscount) { if (ModelState.IsValid) { db.tblDiscount.Add(tbldiscount); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tbldiscount)); }
public ActionResult Edit([Bind(Include = "DiscountID,DiscountCode,DiscountType,DiscountName,DiscountAmount,CreatedBy,UpdatedBy,CreateDate,UpdateDate,IsDelete,IsActive,SchoolID,DeleteBy,DeleteDate")] tblDiscount tbldiscount) { if (ModelState.IsValid) { db.Entry(tbldiscount).State = EntityState.Modified; db.SaveChanges(); TempData["msg"] = "Record Update Successfully"; return(RedirectToAction("Index")); } return(View(tbldiscount)); }
// GET: /Users/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblDiscount tbldiscount = db.tblDiscount.Find(id); if (tbldiscount == null) { return(HttpNotFound()); } return(View(tbldiscount)); }
// GET: /Users/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblDiscount tbldiscount = db.tblDiscount.Find(id); ViewBag.DiscountType = new SelectList(db.tblDiscount, "DiscountID", "DiscountType", tbldiscount.DiscountID); if (tbldiscount == null) { return(HttpNotFound()); } return(View(tbldiscount)); }
public ActionResult AddNewCoupon(tblDiscount model, string Reservationtime) { DateTime?startDate, endDate; int discount = 0; string reservationtime = Reservationtime; string code = GenericSymbols(); if (ModelState.IsValid && !String.IsNullOrEmpty(reservationtime)) { try { startDate = Convert.ToDateTime(reservationtime.Split('-')[0].Trim()); endDate = Convert.ToDateTime(reservationtime.Split('-')[1].Trim()); discount = model.DiscountAmount; var tbl = new tblDiscount { DiscountKey = code, DiscountAmount = discount, StartDateOfDiscount = startDate, EndDateOfDiscount = endDate, UserName = User.Identity.Name, DateChanged = DateTime.Now, DateCreated = DateTime.Now }; db.tblDiscounts.Add(tbl); db.SaveChanges(); TempData["ResultSuccess"] = "Success in adding new coupon!"; return(RedirectToAction("ViewAllCoupons")); } catch (Exception ex) { TempData["ResultError"] = "Error in adding new coupon!"; SendExceptionToAdmin(ex.ToString()); } } // If we got this far, something failed, redisplay form return(View()); }