public IHttpActionResult PutBuyer_LoadProduct(int id, Buyer_LoadProduct buyer_LoadProduct) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != buyer_LoadProduct.Product_ID) { return(BadRequest()); } db.Entry(buyer_LoadProduct).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!Buyer_LoadProductExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PutOrder_Items(string id, Order_Items order_Items) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != order_Items.Order_ID) { return(BadRequest()); } db.Entry(order_Items).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!Order_ItemsExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PutUser(int id, User user) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != user.Id) { return(BadRequest()); } db.Entry(user).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!UserExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PutCart_Item(int ItemID, int CartID, Cart_Item cart_Item) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (ItemID != cart_Item.ItemID && CartID != cart_Item.Cart_ID) { return(BadRequest()); } db.Entry(cart_Item).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { //if (!Cart_ItemExists(id)) //{ // return NotFound(); //} //else //{ // throw; //} } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PutAddress(int id, Address address) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != address.Address_ID) { return(BadRequest()); } db.Entry(address).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!AddressExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult Edit(FormCollection form) { int id = Convert.ToInt32(form["Id"]); if (form["Username"] != null) { string username = form["Username"].ToString(); string email = form["Email"].ToString(); string name = form["Name"].ToString(); string address = form["Address"].ToString(); string gender = form["Gender"].ToString(); string phone = form["Phone"].ToString(); DateTime birthday = Convert.ToDateTime(form["Birthday"]); int role = Convert.ToInt32(form["RoleID"]); string picture = null; string password = form["Password"].ToString(); User user = new User() { Id = id, Username = username, Email = email, Password = password, Name = name, Address = address, Gender = gender, Phone = phone, Birthday = birthday, RoleID = role, Avatar = picture }; db.Entry(user).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } else if (form["idBrand"] != null) { id = Convert.ToInt32(form["idBrand"].ToString()); string name = form["Name"].ToString(); Brand brand = new Brand() { BrandID = id, BrandName = name }; try { db.Entry(brand).State = EntityState.Modified; db.SaveChanges(); return(RedirectToRoute(new { action = "Index", controller = "Brands", area = "Admin" })); } catch { } } return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "BrandID,BrandName")] Brand brand) { if (ModelState.IsValid) { db.Entry(brand).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(brand)); }
public ActionResult Edit(FormCollection form) { int id = Convert.ToInt32(form["id"]); string name = form["Name"].ToString(); MainType type = new MainType() { ID = id, Name = name }; db.Entry(type).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(FormCollection form) { int id = Convert.ToInt32(form["Id"]); string name = form["name"].ToString(); int price = Convert.ToInt32(form["Price"]); int amount = Convert.ToInt32(form["Amount"]); int type = Convert.ToInt32(form["Type"]); int store = Convert.ToInt32(form["Store"]); int brand = Convert.ToInt32(form["Brand"]); string des = form["Description"].ToString(); Product product = new Product() { Product_ID = id, Name = name, Price = price, Amount = amount, TypeID = type, Store_ID = store, Pictures = null, BrandID = brand, Decription = des, status = 0 }; db.Entry(product).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); }