public ActionResult Create([Bind(Include = "creditCardID,userID,owner,cardNumber,code,expiredDate,isDefault,createdDate,updatedDate")] CreditCard creditCard) { if (ModelState.IsValid) { if (Session["userID"] == null) { return(RedirectToAction("Index", "Home")); } int userID = Convert.ToInt32(Session["userID"]); creditCard.userID = userID; creditCard.createdDate = DateTime.Now; creditCard.updatedDate = DateTime.Now; //handle reset default DbContextTransaction transaction = db.Database.BeginTransaction(); if (creditCard.isDefault == 1 && db.CreditCards.Count() > 0) { var creditCardList = db.CreditCards.Where(a => a.userID == userID); foreach (var item in creditCardList) { item.isDefault = 0; db.Entry(item).State = EntityState.Modified; db.SaveChanges(); } } transaction.Commit(); //end db.CreditCards.Add(creditCard); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(creditCard)); }
public ActionResult Approve([Bind(Include = "reviewID")] Review thisReview) { var id = thisReview.reviewID; Review review = db.Reviews.Find(id); review.status = 1; review.displayStatus = "Approved"; review.updatedDate = DateTime.Now; db.Entry(review).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); }
protected void ResetPass_Click(object sender, EventArgs e) { string code = Verification.Text.ToString(); string pass = Password.Text.ToString(); passReset reset = null; using (var ctx = new CVGSEntities()) { reset = ctx.passResets .Where(s => s.resetCode == code).FirstOrDefault(); if (reset != null) { login log = new login(); log.username = reset.username; log.password = pass; if (ModelState.IsValid) { ctx.Entry(log).State = System.Data.Entity.EntityState.Modified; ctx.SaveChanges(); ctx.passResets.Remove(reset); ctx.SaveChanges(); } Response.Redirect("~/Account/Login"); } else { ErrorMessage.Text = "Invalid Verification Code"; } } }
public ActionResult EditProfile([Bind(Include = "userID,username,nickname,gender,dob,phone,email")] User tempUserProfile) { if (ModelState.IsValid) { User user = db.Users.Find(tempUserProfile.userID); user.nickname = tempUserProfile.nickname; user.dob = tempUserProfile.dob; user.gender = tempUserProfile.gender; user.phone = tempUserProfile.phone; user.email = tempUserProfile.email; db.Entry(user).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("ProfileDetail")); } return(View(tempUserProfile)); }
public ActionResult Edit([Bind(Include = "platformID,platformName,createdDate,updatedDate")] Platform platform) { if (ModelState.IsValid) { platform.updatedDate = DateTime.Now; db.Entry(platform).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(platform)); }
public ActionResult Edit([Bind(Include = "categoryID,categoryName,createdDate,updatedDate")] Category category) { if (ModelState.IsValid) { category.updatedDate = DateTime.Now; db.Entry(category).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(category)); }
public ActionResult Edit([Bind(Include = "gameID,title,description,develpoer,publisher,releasedDate,price,categoryID,subCategoryID,createdDate,updatedDate")] Game game) { if (ModelState.IsValid) { db.Entry(game).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.categoryID = new SelectList(db.Categories, "categoryID", "categoryName", game.categoryID); ViewBag.subCategoryID = new SelectList(db.Categories, "categoryID", "categoryName", game.subCategoryID); return(View(game)); }
public ActionResult Edit([Bind(Include = "username,gameId,dateAdded")] wishList wishList) { if (ModelState.IsValid) { db.Entry(wishList).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.gameId = new SelectList(db.games, "id", "name", wishList.gameId); ViewBag.username = new SelectList(db.users, "username", "firstName", wishList.username); return(View(wishList)); }
public ActionResult Edit([Bind(Include = "id,name,description,publisher,publishDate,genre,rating,price")] game game) { if (ModelState.IsValid) { db.Entry(game).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.rating = new SelectList(db.esrb_rating, "ratingCode", "description", game.rating); ViewBag.genre = new SelectList(db.genres, "genreKey", "name", game.genre); ViewBag.genre = new SelectList(db.genres, "genreKey", "name", game.genre); return(View(game)); }
public ActionResult Edit(int id, [Bind(Include = "username,gameId,quantity")] cart cart) { cart.username = Session["User"].ToString(); cart.gameId = id; if (ModelState.IsValid) { db.Entry(cart).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.gameId = new SelectList(db.games, "id", "name", cart.gameId); ViewBag.username = new SelectList(db.users, "username", "firstName", cart.username); return(View(cart)); }
public ActionResult Delivering(int orderID) { if (Session == null || Session["userID"] == null || Session["role"].ToString() != "employee") { return(RedirectToAction("Index", "Home")); } if (orderID.ToString() == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Order order = db.Orders.Find(orderID); if (order == null) { return(HttpNotFound()); } order.status = 2; order.displayStatus = "delivering"; order.updatedDate = DateTime.Now; db.Entry(order).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); }
protected void ChangePass_Click(object sender, EventArgs e) { String oldPassword = ""; String newPassword = ""; String user = Session["User"].ToString(); LoginModel logins = null; using (var ctx = new CVGSEntities()) { logins = ctx.logins .Where(s => s.username == user) .Select(s => new LoginModel() { user = s.username, pword = s.password }).FirstOrDefault <LoginModel>(); } if (OldPass.Text.Trim() != null || OldPass.Text.Trim() != "") { oldPassword = OldPass.Text.Trim(); } if (NewPassword.Text.Trim() != null || NewPassword.Text.Trim() != "") { newPassword = NewPassword.Text.Trim(); } if (logins.pword == oldPassword) { login log = new login(); log.username = user; log.password = newPassword; using (var ctx = new CVGSEntities()) { if (ModelState.IsValid) { ctx.Entry(log).State = EntityState.Modified; ctx.SaveChanges(); } } Response.Redirect("/Default"); } else { ErrorMessage.Text = "Current password does not match entered value."; } }
public ActionResult Create([Bind(Include = "addressID,userID,province,city,address1,isDefault,createdDate,updatedDate")] Address address) { if (ModelState.IsValid) { if (Session == null || Session["userID"] == null) { return(RedirectToAction("Index", "Home")); } int userID = Convert.ToInt32(Session["userID"]); address.userID = userID; address.createdDate = DateTime.Now; address.updatedDate = DateTime.Now; //handle reset default address DbContextTransaction transaction = db.Database.BeginTransaction(); if (address.isDefault == 1 && db.Addresses.Count() > 0) { var addressList = db.Addresses.Where(a => a.userID == userID); foreach (var item in addressList) { item.isDefault = 0; db.Entry(item).State = EntityState.Modified; db.SaveChanges(); } } transaction.Commit(); //end db.Addresses.Add(address); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(address)); }
public ActionResult Edit([Bind(Include = "eventID,title,description,startDate,endDate,createdDate,updatedDate")] Event @event) { if (ModelState.IsValid) { @event.updatedDate = DateTime.Now; if (@event.startDate > @event.endDate) { ModelState.AddModelError("endDate", "End Date can not earier than start date"); return(View(@event)); } db.Entry(@event).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(@event)); }
public ActionResult Edit([Bind(Include = "gameID,title,description,develpoer,publisher,releasedDate,price,categoryID,subCategoryID,createdDate,updatedDate")] Game game) { if (Session == null || Session["userID"] == null) { return(RedirectToAction("Index", "Home")); } if (ModelState.IsValid) { game.updatedDate = DateTime.Now; db.Entry(game).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.categoryID = new SelectList(db.Categories, "categoryID", "categoryName", game.categoryID); var subCategoryList = new SelectList(db.Categories, "categoryID", "categoryName", game.subCategoryID).ToList(); subCategoryList.Insert(0, (new SelectListItem { Text = "None", Value = "0" })); return(View(game)); }