public ActionResult Success(FormCollection frc) { DonHang donhang = new DonHang { Email = frc["khEmail"], MaTT = 1, DiaChiNguoiNhan = frc["khDiachi"], SDT = frc["khSodt"], TongTien = Int32.Parse(frc["TTien"]), }; db.DonHangs.Add(donhang); db.SaveChanges(); foreach (var billdetail in ShoppingCart) { ChiTietDonHang ctdh = new ChiTietDonHang() { MaDH = donhang.MaDH, MaSP = billdetail.SanPham.MaSP, SoLuong = billdetail.SoLuong, }; db.ChiTietDonHangs.Add(ctdh); db.SaveChanges(); } ShoppingCart.Clear(); return(View("Success")); }
public ActionResult Create(string roleId, string userId) { var role = db.AspNetRoles.Find(roleId); var user = db.AspNetUsers.Find(userId); role.AspNetUsers.Add(user); db.Entry(role).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index", "AspNetRoles")); }
public ActionResult Create(SanPham model) { ValidateProduct(model); if (ModelState.IsValid) { db.SanPhams.Add(model); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(model)); }
public ActionResult Create(AspNetRole aspNetRole) { if (ModelState.IsValid) { aspNetRole.Id = Guid.NewGuid().ToString(); db.AspNetRoles.Add(aspNetRole); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(aspNetRole)); }
public ActionResult Create([Bind(Include = "MaDH,Email,MaTT,DiaChiNguoiNhan,SDT")] DonHang donHang) { if (ModelState.IsValid) { donHang.idKH = User.Identity.GetUserId(); db.DonHangs.Add(donHang); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.MaTT = new SelectList(db.TrangThaiDonHangs, "MaTT", "TrangThai", donHang.MaTT); return(View(donHang)); }
public ActionResult Create([Bind(Include = "MaCTDH,MaDH,MaSP,SoLuong")] ChiTietDonHang chiTietDonHang) { if (ModelState.IsValid) { db.ChiTietDonHangs.Add(chiTietDonHang); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.MaDH = new SelectList(db.DonHangs, "MaDH", "Email", chiTietDonHang.MaDH); ViewBag.MaSP = new SelectList(db.SanPhams, "MaSP", "MaLoaiSP", chiTietDonHang.MaSP); return(View(chiTietDonHang)); }
public ActionResult Profile(KhachHang user) { db.Entry(user).State = EntityState.Modified; db.SaveChanges(); return(View(user)); }