예제 #1
0
        public ActionResult Create([Bind(Include = "Id,Name")] Models.ProductMVC product)
        {
            if (ModelState.IsValid)
            {
                var item = new Modell.Product()
                {
                    Id = product.Id, ProductName = product.Name
                };
                new DAL.Repository.ProductRepository()
                .Insert(item);
                return(RedirectToAction("Index"));
            }

            return(View(product));
        }
예제 #2
0
        public ActionResult Edit([Bind(Include = "Id,Name")] Models.ProductMVC product)
        {
            if (ModelState.IsValid)
            {
                var item = new DAL.Repository.ProductRepository()
                           .GetById(product.Id)
                           .FirstOrDefault();

                if (item != null)
                {
                    item.ProductName = product.Name;
                    new DAL.Repository.ProductRepository()
                    .Update(item);

                    return(RedirectToAction("Index"));
                }
            }
            return(View(product));
        }