Exemplo n.º 1
0
        public ActionResult Create(ProductType producttype)
        {
            if (ModelState.IsValid)
            {
                var newId = _db.ProductTypes.Max(x => x.Id) + 1;
                producttype.Id = newId;
                _db.ProductTypes.Add(Mapper.Map<SimGame.Domain.ProductType>(producttype));
                var product = new SimGame.Domain.Product
                {
                    IsCityStorage = true,
                    ProductTypeId = newId
                };
                _db.Products.Add(product);
                _db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(producttype);
        }
Exemplo n.º 2
0
 public ActionResult Edit(ProductType producttype)
 {
     if (ModelState.IsValid)
     {
         var modified = EntityState.Modified;
         _db.Entry(producttype).State = modified;
         _db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(producttype);
 }