public JsonResult SortProducts(int[] productItems) { var jsonSuccessResult = new JsonSuccessResult(); try { int order = 0; foreach (var item in productItems) { PriceListProducts.UpdateOrderID(item, order); order++; } jsonSuccessResult.Success = true; } catch (Exception ex) { jsonSuccessResult.Errors = new string[] { ex.Message }; jsonSuccessResult.Success = false; } return(new JsonResult() { Data = jsonSuccessResult }); }
public ActionResult Edit(PriceListProduct priceListProduct) { try { priceListProduct.LastUpdate = DateTime.Now; ViewBag.Success = true; if (priceListProduct.ID == -1) { PriceListProducts.Insert(priceListProduct); UserNotifications.Send(UserID, String.Format("جدید - محصولات لیست بنک داری '{0}'", priceListProduct.Title), "/Admin/PriceListProducts/Edit/" + priceListProduct.ID, NotificationType.Success); priceListProduct = new PriceListProduct(); } else { PriceListProducts.Update(priceListProduct); } } catch (Exception ex) { SetErrors(ex); } return(ClearView(priceListProduct)); }
public ActionResult Edit(int?id) { PriceListProduct priceListProduct; if (id.HasValue) { priceListProduct = PriceListProducts.GetByID(id.Value); } else { priceListProduct = new PriceListProduct(); } return(View(priceListProduct)); }
public JsonResult Delete(int id) { var jsonSuccessResult = new JsonSuccessResult(); try { PriceListProducts.Delete(id); jsonSuccessResult.Success = true; } catch (Exception ex) { jsonSuccessResult.Errors = new string[] { ex.Message }; jsonSuccessResult.Success = false; } return(new JsonResult() { Data = jsonSuccessResult }); }
public JsonResult SaveChanges(int id, string newValue, PriceListFieldName priceListFieldName) { var jsonSuccessResult = new JsonSuccessResult(); try { string oldValue = String.Empty; // Update Row PriceListProducts.SaveChanges(id, newValue, priceListFieldName, out oldValue); // Insert Log #region Log PriceListLog log = new PriceListLog { OldValue = oldValue, NewValue = newValue, PriceListFieldName = priceListFieldName, PriceListProductID = id, LastUpdate = DateTime.Now }; PriceListLogs.Inset(log); #endregion Log jsonSuccessResult.Success = true; } catch (Exception ex) { jsonSuccessResult.Errors = new string[] { ex.Message }; jsonSuccessResult.Success = false; } return(new JsonResult() { Data = jsonSuccessResult }); }
public JsonResult Get(int pageIndex, int pageSize, string pageOrder, string title) { if (pageOrder.Trim() == "ID") { pageOrder = "OrderID"; } var list = PriceListProducts.Get(pageIndex, pageSize, pageOrder, title); int total = PriceListProducts.Count(title); int totalPage = (int)Math.Ceiling((decimal)total / pageSize); if (pageSize > total) { pageSize = total; } if (list.Count < pageSize) { pageSize = list.Count; } JsonResult result = new JsonResult() { Data = new { TotalPages = totalPage, PageIndex = pageIndex, PageSize = pageSize, Rows = list }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }; return(result); }