public ActionResult Create([Bind(Include = "CategoryId,CategoryStatus,CategoryParentId,CategoryName")] Category category) { if (ModelState.IsValid) { db.Categories.Add(category); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(category)); }
public ActionResult Create([Bind(Include = "BusinessId,BusinessName")] Business business) { if (ModelState.IsValid) { db.Businesses.Add(business); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(business)); }
public ActionResult Create(Size s) { if (ModelState.IsValid) { s.SizeStatus = s.SizeStatus ?? false; db.Sizes.Add(s); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(s)); }
public ActionResult Create([Bind(Include = "UserId,UserName,Password,Email,UserStatus")] User user) { if (ModelState.IsValid) { db.Users.Add(user); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(user)); }
public ActionResult Create([Bind(Include = "VoucherId,VoucherName,Code,DiscountPercent,Remain,ExpiredAt")] Voucher voucher) { if (ModelState.IsValid) { voucher.Code = voucher.Code.ToUpper().ToString(); db.Vouchers.Add(voucher); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(voucher)); }
public ActionResult Create([Bind(Include = "PermissonId,PermissonName,PermissonDescription,BusinessId")] Permisson permisson) { if (ModelState.IsValid) { db.Permissons.Add(permisson); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.BusinessId = new SelectList(db.Businesses, "BusinessId", "BusinessName", permisson.BusinessId); return(View(permisson)); }
public ActionResult Create([Bind(Include = "AdminId,AdminPassword,AdminUsername,AdminIsDeleted,AdminIsDisabled,IsSuper")] ShoesProjectModels.Model.Admin admin) { if (ModelState.IsValid) { admin.AdminPassword = Util.Utility.getHashedMD5(admin.AdminUsername + admin.AdminPassword); db.Admins.Add(admin); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(admin)); }
public ActionResult Create([Bind(Include = "ColorId,ColorValue,ColorCode")] Color color) { color.ColorStatus = true; if (ModelState.IsValid) { db.Colors.Add(color); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(color)); }
public ActionResult Create([Bind(Include = "OrderId,UserId,VoucherId,Address,PhoneNumber,ProgressStatus,OrderStatus")] Order order) { if (ModelState.IsValid) { db.Orders.Add(order); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.UserId = new SelectList(db.Users, "UserId", "UserName", order.UserId); ViewBag.VoucherId = new SelectList(db.Vouchers, "VoucherId", "VoucherName", order.VoucherId); return(View(order)); }
public ActionResult Create([Bind(Include = "OrderId,ProductId,ColorId,SizeId,Quantity,OldPrice")] OrdersDetail ordersDetail) { if (ModelState.IsValid) { db.OrdersDetails.Add(ordersDetail); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ColorId = new SelectList(db.Colors, "ColorId", "ColorValue", ordersDetail.ColorId); ViewBag.OrderId = new SelectList(db.Orders, "OrderId", "Address", ordersDetail.OrderId); ViewBag.ProductId = new SelectList(db.Products, "ProductId", "ProductName", ordersDetail.ProductId); ViewBag.SizeId = new SelectList(db.Sizes, "SizeId", "SizeValue", ordersDetail.SizeId); return(View(ordersDetail)); }
public int Create([Bind(Include = "ProductId,ProductName,CategoryId,Instock,BrandId,ProductPrice,ProductDescription,ProductDiscount,ProductFeatureImage,ProductStatus")] Product product) { if (ModelState.IsValid) { db.Products.Add(product); db.SaveChanges(); return(product.ProductId); } return(0); }
public ActionResult ForgotPassword(string Email) { var user = db.Users.SingleOrDefault(x => x.Email.Equals(Email)); if (user != null) { user.Password = Utility.getHashedMD5("1234"); db.Entry(user).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); string content = System.IO.File.ReadAllText(Server.MapPath("~/Template/content.html")); content = content.Replace("{{CustomerName}}", user.UserName); content = content.Replace("{{Email}}", user.Email); new MailHelper().SendMail(user.Email, "Password Reset", content); return(RedirectToAction("Index", "Login")); } else { return(RedirectToAction("ForgotPassword")); } }
//[ValidateAntiForgeryToken] public ActionResult Create([Bind(Include = "BrandId,BrandName,BrandImage")] Brand brand) { if (ModelState.IsValid) { db.Brands.Add(brand); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(brand)); }
public ActionResult Register(User u) { try { var user = db.Users.SingleOrDefault(x => x.Email.Equals(u.Email)); if (user == null) { u.Password = Utility.getHashedMD5(u.Password); db.Users.Add(u); db.SaveChanges(); TempData["smg"] = "Đăng ký Thành Công"; return(RedirectToAction("Index")); } else { TempData["smg"] = "Email đã đc đăng ký "; return(RedirectToAction("Index")); } } catch (Exception) { throw; } }
public ActionResult CartAddress(Order or, string code) { try { if (Session["Cart"] != null) { int u = (int)Session["UserId"]; var voucher = db.Vouchers.SingleOrDefault(x => x.Code.Equals(code) && x.Remain > 0 && (x.ExpiredAt >= DateTime.Now || x.ExpiredAt == null)); User us = db.Users.SingleOrDefault(x => x.UserId == u); if (voucher != null) { or.UserId = us.UserId; or.VoucherId = voucher.VoucherId; or.CreatedAt = DateTime.Now.ToLocalTime(); db.Orders.Add(or); db.SaveChanges(); Session["OrderId"] = or.OrderId; var lst = (List <CartItem>)Session["Cart"]; foreach (var item in lst) { var ordetail = new OrdersDetail(); ordetail.OrderId = or.OrderId; ordetail.ProductId = item.Product.ProductId; ordetail.ColorId = item.Color.ColorId; ordetail.SizeId = item.Size.SizeId; ordetail.Quantity = item.Quantity; if (item.Product.ProductDiscount != null) { ordetail.OldPrice = item.Product.ProductPrice - ((item.Product.ProductPrice * (int)item.Product.ProductDiscount) / 100); } else { ordetail.OldPrice = item.Product.ProductPrice; } db.OrdersDetails.Add(ordetail); db.SaveChanges(); } Session["Cart"] = null; } else { or.UserId = us.UserId; or.VoucherId = 1; or.CreatedAt = DateTime.Now.ToLocalTime(); db.Orders.Add(or); db.SaveChanges(); Session["OrderId"] = or.OrderId; var lst = (List <CartItem>)Session["Cart"]; foreach (var item in lst) { var ordetail = new OrdersDetail(); ordetail.OrderId = or.OrderId; ordetail.ProductId = item.Product.ProductId; ordetail.ColorId = item.Color.ColorId; ordetail.SizeId = item.Size.SizeId; ordetail.Quantity = item.Quantity; if (item.Product.ProductDiscount != null) { ordetail.OldPrice = item.Product.ProductPrice - ((item.Product.ProductPrice * (int)item.Product.ProductDiscount) / 100); } else { ordetail.OldPrice = item.Product.ProductPrice; } db.OrdersDetails.Add(ordetail); db.SaveChanges(); } Session["Cart"] = null; } return(RedirectToAction("CartPayment")); } else { return(RedirectToAction("Index", "Home")); } } catch (Exception ex) { ViewBag.aaa = " loi " + ex; return(View()); throw; } }