public ActionResult Edit([Bind(Include = "registeredUserId,fullName,userName,password,role,PhoneNo,Email,ShipAddress")] Customer customer) { if (ModelState.IsValid) { int adID = (from x in db.Customer where x.registeredUserId == customer.registeredUserId select x.ShipAddress.AddressID).First(); customer.ShipAddress.AddressID = adID; Address newAdd = new Address { AddressID = customer.ShipAddress.AddressID, Street = customer.ShipAddress.Street, State = customer.ShipAddress.State, City = customer.ShipAddress.City, PostCode = customer.ShipAddress.PostCode, Country = customer.ShipAddress.Country }; customer.ShipAddress = newAdd; db.Entry(customer.ShipAddress).State = EntityState.Modified; db.Entry(customer).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Details", customer.registeredUserId)); } else { return(View(customer)); } }
public ActionResult Edit([Bind(Include = "Id,Email,ForName,SurName,Phone,Photo")] User user) { if (ModelState.IsValid) { db.Entry(user).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(user)); }
public ActionResult Edit([Bind(Include = "Id,Email")] Newsletter newsletter) { if (ModelState.IsValid) { db.Entry(newsletter).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(newsletter)); }
public ActionResult Edit([Bind(Include = "ID,LastUpdate")] Chat_Room chat_Room) { if (ModelState.IsValid) { db.Entry(chat_Room).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(chat_Room)); }
public ActionResult Edit([Bind(Include = "Id,CategoryName")] ProductsCategory productsCategory) { if (ModelState.IsValid) { db.Entry(productsCategory).State = EntityState.Modified; db.SaveChanges(); return(Json(new { text = "Added", Id = productsCategory.Id, Name = productsCategory.CategoryName })); } return(Json("Error")); }
public ActionResult Edit([Bind(Include = "OrderId,PaymentType,TotalPrice,ShipFee")] Order order) { if (ModelState.IsValid) { db.Entry(order).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(order)); }
public ActionResult Edit([Bind(Include = "Id,info,Email,Name,Street,ProductId,City")] Purchase purchase) { if (ModelState.IsValid) { db.Entry(purchase).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ProductId = new SelectList(db.Products, "Id", "Thumb", purchase.ProductId); return(View(purchase)); }
public async Task <Address> Update(Address entity) { try { _db.Entry(entity).CurrentValues.SetValues(entity); await _db.SaveChangesAsync(); return(entity); } catch (Exception ex) { //log exception return(null); } }
public ActionResult EditBook([Bind(Include = "BookId,Title,Publisher,Year,ISBN,Author,Category,Price", Exclude = "CoverPage")] Book book) { HttpPostedFileBase poImgFile = Request.Files["CoverPage"]; string path = @"\Images/" + poImgFile.FileName; poImgFile.SaveAs(Server.MapPath("~") + @"\" + path); book.CoverPage = path; if (ModelState.IsValid) { db.Entry(book).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("IndexBook")); } return(View(book)); }