コード例 #1
0
 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();
 }
コード例 #2
0
 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);
     }
 }
コード例 #3
0
        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;
        }
コード例 #4
0
 //[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();
 }
コード例 #5
0
 //[HttpPost]
 public ActionResult ProductDetails(Int32 id)
 {
     ProductManager productManager = new ProductManager();
     return PartialView(productManager.GetProduct(id));
 }
コード例 #6
0
        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;
        }