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 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 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 ResetPassword(int id) { if (ModelState.IsValid) { db.ResetPassword(id); db.SaveChanges(); } return(RedirectToAction("Index")); }
public ActionResult Create(FormCollection form) { int id = Convert.ToInt32(form["id"]); string name = form["Name"].ToString(); Brand newBrand = new Brand() { BrandID = id, BrandName = name }; db.Brands.Add(newBrand); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create(FormCollection form) { int id = Convert.ToInt32(form["id"]); string name = form["Name"].ToString(); Main_Type type = new Main_Type() { Name = name }; db.Main_Type.Add(type); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create(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, BrandID = brand, Decription = des }; db.Products.Add(product); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult FacebookCallback(string code) { var fb = new FacebookClient(); dynamic result = fb.Post("oauth/access_token", new { client_id = ConfigurationManager.AppSettings["FbAppID"], client_secret = ConfigurationManager.AppSettings["FbAppSecret"], redirect_uri = RedirectUri.AbsoluteUri, code = code }); var accessToken = result.access_token; if (!string.IsNullOrEmpty(accessToken)) { fb.AccessToken = accessToken; dynamic me = fb.Get("me?fields=first_name, middle_name,last_name,id,email"); string email = me.email; //string username = me.email; //string name = me.first_name; try { db.sp_InsUserFb(email); db.SaveChanges(); var user = db.Users.Where(x => x.Email == email).FirstOrDefault(); if (user != null) { Session["userID"] = user.Id; Session["username"] = user.Email; if (user.Avatar == null) { Session["Avatar"] = "#.png"; } BuyerAddressClient buyerAddressClient = new BuyerAddressClient(); var addressList = buyerAddressClient.find(Convert.ToInt32(Session["userID"])); Session["Address_ID"] = addressList.Where(x => x.default_address == 1).Select(x => x.Address_ID).FirstOrDefault(); return(RedirectToAction("Index", "MainPage", new { Area = "Buyer" })); } } catch { Response.Write("<script>alert('Invalid Email or Password')</script>"); return(View("Error")); } } else { Response.Write("<script>alert('Invalid Email or Password')</script>"); return(View("Error")); } Response.Write("<script>alert('Invalid Email or Password')</script>"); return(View("Error")); }
public ActionResult showEditProfile() { int id = Convert.ToInt32(Session["userID"]); string name = Request["Username"]; string email = Request["email"]; string address = Request["address"]; string gender = Request["Gender"]; //không thay đổi giới tính if (gender == null) { gender = db.Users.Where(x => x.Id == id).Select(x => x.Gender).FirstOrDefault(); } string phone = Request["phone"]; DateTime date = Convert.ToDateTime(Request["date"]); string avatar = Session["Avatar"].ToString(); db.sp_EditProfile(id, name, email, address, gender, phone, date, avatar); db.SaveChanges(); //return RedirectToAction("EditProFile"); if (Session["userID"] != null) { id = Convert.ToInt32(Session["userID"]); ViewBag.User = db.Users.Where(x => x.Id == id).FirstOrDefault(); date = Convert.ToDateTime(ViewBag.User.Birthday); string day = date.Day.ToString(); string month = date.Month.ToString(); if (date.Day < 10) { day = "0" + date.Day; } if (date.Month < 10) { month = "0" + date.Month; } ViewBag.birthday = date.Year + "-" + month + "-" + day; } return(PartialView("EditProfile")); }
// GET: api/ChangeStatus public IHttpActionResult ChangeStatus(string id, int status) { db.ChangeStatus(id, status); db.SaveChanges(); return(Ok()); }