示例#1
0
 public void Insert(ProdCategoryView model)
 {
     using (var rep = new ProdCategoryRepository())
        {
        rep.Insert(ConvertToProduct(model));
        }
 }
示例#2
0
        private static ProdCategory ConvertToProduct(ProdCategoryView modelView)
        {
            var dev = new ProdCategory
               {

               CategoryId = modelView.CategoryId,
               CategoryName = modelView.CategoryName,

               };
               return dev;
        }
示例#3
0
 public ActionResult Update(ProdCategoryView model, int id)
 {
     try
     {
         if (!ModelState.IsValid) return View(model);
         model.CategoryId = id;
         obj.Update(model);
         return RedirectToAction("Index");
     }
     catch
     {
         return View(model);
     }
 }
示例#4
0
 public ActionResult Create(ProdCategoryView model)
 {
     var user = User.Identity.Name;
     try
     {
         if (!ModelState.IsValid) return View(model);
         obj.Insert(model);
         return RedirectToAction("Index");
     }
     catch
     {
         return View(model);
     }
 }
示例#5
0
        public void Update(ProdCategoryView modelView)
        {
            using (var rep = new ProdCategoryRepository())
               {
               var dev = rep.GetById(modelView.CategoryId);

               if (dev != null)
               {

                   dev.CategoryName = modelView.CategoryName;

                   rep.Update(dev);
               }
               }
        }