예제 #1
0
 //
 // GET: /Product/Create
 public ActionResult Create(int id)
 {
     CategoryRepo cr = new CategoryRepo();
     if (cr.ValidateID(id))
     {
         ProductModel p = new ProductModel();
         p.Category = id;
         return View(p);
     }
     return RedirectToAction("Index", "Category");
 }
예제 #2
0
파일: ProductRepo.cs 프로젝트: MikE87/v-mag
        public void EditProduct(int id, ProductModel product)
        {
            var pr = context.ProductModels.Single(p => p.ID == id);

            pr.Name = product.Name;
            pr.Description = product.Description;
            pr.Count = product.Count;
            pr.Price = product.Price;

            context.SubmitChanges();
        }
예제 #3
0
 public ActionResult Create(int id, ProductModel product)
 {
     try
     {
         product.Category = id;
         if (ModelState.IsValid)
         {
             products.AddProduct(product);
             if(Request.IsAjaxRequest())
                 return Json(new { success = true });
             return RedirectToAction("Index", "Category", new { id=id });
         }
         if (Request.IsAjaxRequest())
             return Json(new { success = false, errors = ModelState.Values.SelectMany(v => v.Errors) });
         return View(product);
     }
     catch (Exception e)
     {
         if (Request.IsAjaxRequest())
             return Json(new { success = false, error = e.Message });
         return View();
     }
 }
예제 #4
0
파일: ProductRepo.cs 프로젝트: MikE87/v-mag
 public void AddProduct(ProductModel product)
 {
     context.ProductModels.InsertOnSubmit(product);
     context.SubmitChanges();
 }
예제 #5
0
 public ActionResult Edit(int id, ProductModel product)
 {
     try
     {
         if (ModelState.IsValid)
         {
             products.EditProduct(id, product);
             if (Request.IsAjaxRequest())
                 return Json(new { success = true });
             return RedirectToAction("Details", "Product", new { id=id });
         }
         if (Request.IsAjaxRequest())
             return Json(new { success = false, errors = ModelState.Values.SelectMany(v => v.Errors) });
         product.ID = id;
         return View(product);
     }
     catch(Exception e)
     {
         if (Request.IsAjaxRequest())
             return Json(new { success = false, error = e.Message });
         return View();
     }
 }
예제 #6
0
 partial void DeleteProductModel(ProductModel instance);
예제 #7
0
 partial void UpdateProductModel(ProductModel instance);
예제 #8
0
 partial void InsertProductModel(ProductModel instance);
예제 #9
0
		private void detach_ProductModels(ProductModel entity)
		{
			this.SendPropertyChanging();
			entity.CategoryModel = null;
		}