public ActionResult DeletePromotion(long PROMOTION_ID = 0) { if (Request.IsAjaxRequest()) { if (ModelState.IsValid && PROMOTION_ID > 0) { using (var service = new ManagePromotionService()) { var deleteResult = service.DeletePromotion(PROMOTION_ID); JsonResult result = Json(new { statusCode = deleteResult ? Constant.SUCCESSFUL : Constant.INTERNAL_SERVER_ERROR }, JsonRequestBehavior.AllowGet); return(result); } } else { var errors = ModelState.Where(x => x.Value.Errors.Count > 0).Select(x => new { x.Key, x.Value.Errors }).ToArray(); } } return(new EmptyResult()); }
public ActionResult Edit(TblPromotion model) { try { using (ManagePromotionService service = new ManagePromotionService()) { if (ModelState.IsValid) { bool isNew = false; TblPromotion entity = new TblPromotion(); if (model.id == 0) { isNew = true; service.InsertPromotion(model); JsonResult result = Json(new { isNew = isNew }, JsonRequestBehavior.AllowGet); return(result); } else { isNew = false; service.UpdatePromotion(model); JsonResult result = Json(new { isNew = isNew }, JsonRequestBehavior.AllowGet); return(result); } } else { var ErrorMessages = ModelState.Where(x => x.Value.Errors.Count > 0).Select(x => new { x.Key, x.Value.Errors }).ToArray(); } return(new EmptyResult()); } } catch (Exception ex) { Response.StatusCode = (int)System.Net.HttpStatusCode.BadRequest; System.Web.HttpContext.Current.Session["ERROR"] = ex; return(new EmptyResult()); } }
public ActionResult List(DataTableModel dt, TblPromotion condition) { if (ModelState.IsValid) { using (ManagePromotionService service = new ManagePromotionService()) { int total_row = 0; var dataList = service.SearchPromotionList(dt, condition, out total_row); int order = 1; int totalRowCount = dataList.Count(); int lastItem = dt.iDisplayLength + dt.iDisplayStart; var result = Json( new { sEcho = dt.sEcho, iTotalRecords = total_row, iTotalDisplayRecords = total_row, aaData = (from i in dataList select new object[] { i.id, order++, i.PromotionName != null ? HttpUtility.HtmlEncode(i.PromotionName) : String.Empty, i.PriceMin, i.PriceMax, i.Discount.HasValue ? i.Discount.Value + "%" : "", i.Status == true? "Hiển thị" : "Ẩn", i.del_flg }) }); result.MaxJsonLength = Int32.MaxValue; return(result); } } return(new EmptyResult()); }