Ejemplo n.º 1
0
        public IHttpActionResult PutItem(int id, Item item)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != item.Id_Item)
            {
                return(BadRequest());
            }

            db.Entry(item).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ItemExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult PutBasket_Product(int id, Basket_Product basket_Product)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != basket_Product.Id_Basket)
            {
                return(BadRequest());
            }

            db.Entry(basket_Product).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!Basket_ProductExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Ejemplo n.º 3
0
 public ActionResult Contact(Contact contact)
 {
     if (ModelState.IsValid)
     {
         using (var ctx = new ShoppingStoreDB())
         {
             ctx.Contacts.Add(contact);
             ctx.SaveChanges();
         }
     }
     return(View(contact));
 }
Ejemplo n.º 4
0
 public ActionResult AddCategory(Category category)
 {
     if (ModelState.IsValid)
     {
         using (var ctx = new ShoppingStoreDB())
         {
             ctx.Categories.Add(category);
             ctx.SaveChanges();
         }
     }
     //return View(category);
     return(RedirectToAction("Categories"));
 }
Ejemplo n.º 5
0
        public ActionResult Delete(int id)
        {
            using (var ctx = new ShoppingStoreDB())
            {
                var product = ctx.Products.Find(id);
                if (product != null)
                {
                    ctx.Products.Remove(product);
                    ctx.SaveChanges();
                }
            }

            return(RedirectToAction("ProductsGrid"));
        }
Ejemplo n.º 6
0
        public ActionResult Delete(int id)
        {
            using (var categ = new ShoppingStoreDB())
            {
                var category = categ.Categories.Find(id);
                if (category != null)
                {
                    categ.Categories.Remove(category);
                    categ.SaveChanges();
                }
            }

            return(RedirectToAction("Categories"));
        }
Ejemplo n.º 7
0
        public ActionResult Delete(int id)
        {
            using (var ctx = new ShoppingStoreDB())
            {
                var contact = ctx.Contacts.Find(id);
                if (contact != null)
                {
                    ctx.Contacts.Remove(contact);
                    ctx.SaveChanges();
                }
            }

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 8
0
 public ActionResult Edit(Category category)
 {
     if (ModelState.IsValid)
     {
         using (var ctx = new ShoppingStoreDB())
         {
             if (category.Id_Category > 0)
             {
                 ctx.UpdateCategory(category);
             }
             else
             {
                 ctx.Categories.Add(category);
                 ctx.SaveChanges();
             }
         }
     }
     return(RedirectToAction("Categories"));
 }