public JsonResult DeleteProduct(Int32 id) { try { ProductManager operationManager = new ProductManager(); operationManager.DeleteProduct(id); } catch(Exception e) { LogSystem.Instance.PublishErrorMassage(ErrorDictionary.DB_HAVE_NOT_ITEM); } return PrepareJsonResult(); }
public ActionResult CreateNewProduct(ProductModel product) { if (ModelState.IsValid) { product.Quantity = 0; ProductManager productManager = new ProductManager(); productManager.AddNewProduct(product); ProductModel newProduct = new ProductModel(); ViewBag.Massege = "Saccess!!!"; return PartialView("CreateNewProduct", newProduct); } else { ModelState.AddModelError("", "Data is not valid"); return PartialView("CreateNewProduct", product); } }
public OperationModel CreateNewOperation(int id) { OperationModel newOperation = new OperationModel(); newOperation.ProductId = id; ProductManager productMamager = new ProductManager(); newOperation.ProductName = productMamager.GetProduct(id).Name; List<SelectListItem> list = new List<SelectListItem>(); foreach(var operation in _DbOperationType) { list.Add(new SelectListItem { Value = operation.Value.ToString(), Text = operation.Key, }); } newOperation.ListTypeOperation = new SelectList(list, "Value", "Text"); return newOperation; }
//[HttpPost] public JsonResult SaveChange(Int32 Id, String Name, Decimal Price) { try { if (ModelState.IsValid) { ProductManager productManager = new ProductManager(); ProductModel updatingProduct = productManager.GetProduct(Id); updatingProduct.Name = Name; updatingProduct.Price = Price; productManager.UpdateProduct(updatingProduct); } else { ModelState.AddModelError("", "Data is not valid"); } } catch(Exception e) { LogSystem.Instance.PublishErrorMassage(ErrorDictionary.MASSAGE_UNNOUN_ERROR); } return PrepareJsonResult(); }
//[HttpPost] public ActionResult ProductDetails(Int32 id) { ProductManager productManager = new ProductManager(); return PartialView(productManager.GetProduct(id)); }
public JsonResult GetProductsList(String sidx, String sord, Int32? page, Int32? rows, Boolean? _search) { ProductManager productManager = new ProductManager(page.Value, rows.Value); List<ProductModel> productsList = productManager.GetPageProduct(sidx, sord); JsonResult result; int countRows = productManager.GetCountProduct(); result = new JsonResult() { Data = new { page = page, total = productManager.GetCountPage(), records = productManager.GetCountProduct(), rows = productsList } }; return result; }