// PUT api/NhaXuatBan/5 public IHttpActionResult PutNHA_XUAT_BAN(long id, NHA_XUAT_BAN nha_xuat_ban) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != nha_xuat_ban.MA_NXB) { return(BadRequest()); } db.Entry(nha_xuat_ban).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!NHA_XUAT_BANExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
// PUT api/DanhMuc/5 public IHttpActionResult PutDANH_MUC(long id, DANH_MUC danh_muc) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != danh_muc.MA_DM) { return(BadRequest()); } db.Entry(danh_muc).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!DANH_MUCExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
// PUT api/Sach/5 public IHttpActionResult PutSACH(long id, SACH sach) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != sach.MA_SACH) { return(BadRequest()); } db.Entry(sach).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!SACHExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult Create([Bind(Include = "MA_DM,TEN_DM")] DANH_MUC danh_muc) { if (ModelState.IsValid) { db.DANH_MUC.Add(danh_muc); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(danh_muc)); }
public ActionResult Create([Bind(Include = "USERNAME,PASSWORD,IDQH,XACTHUC,BARCODE,EMAIL,HO_TEN,DIA_CHI")] NGUOI_DUNG nguoi_dung) { if (ModelState.IsValid) { db.NGUOI_DUNG.Add(nguoi_dung); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(nguoi_dung)); }
public ActionResult Create([Bind(Include = "MA_NXB,TEN_NXB")] NHA_XUAT_BAN nha_xuat_ban) { if (ModelState.IsValid) { db.NHA_XUAT_BAN.Add(nha_xuat_ban); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(nha_xuat_ban)); }
public ActionResult Create([Bind(Include = "MA_HD,USERNAME,IDTT,DIA_CHI,HO_TEN,DIEN_THOAI,NGAYDATHANG,GHI_CHU,TONG_TIEN")] HOA_DON hoa_don) { if (ModelState.IsValid) { db.HOA_DON.Add(hoa_don); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(hoa_don)); }
//kiểm tra khớp chuỗi sau khi nhấn confirm public bool CheckBarCode(string username, string email, string barcode) { NGUOI_DUNG check = db.NGUOI_DUNG.SingleOrDefault(p => p.EMAIL == email && p.USERNAME == username && p.BARCODE == barcode && p.XACTHUC == 1); if (check != null) //khớp --> confirm { db.NGUOI_DUNG.Where(p => p.USERNAME == username).SingleOrDefault().XACTHUC = 0; db.SaveChanges(); return(true); } return(false); }
public ActionResult Order(HoaDonVM model) { try { //lấy giỏ hàng List <Item> orders = ((GioHang)(Session["cart"])).List; //lấy người dùng NGUOI_DUNG user = (NGUOI_DUNG)(Session["nguoidung"]); //tạo hóa đơn HOA_DON hd = new HOA_DON { USERNAME = user.USERNAME, IDTT = 0, NGAYDATHANG = DateTime.Now.Date, DIA_CHI = model.DIA_CHI, DIEN_THOAI = model.DIEN_THOAI, GHI_CHU = model.GHI_CHU, HO_TEN = model.HO_TEN, TONG_TIEN = 0 }; db.HOA_DON.Add(hd); db.SaveChanges(); //tạo chi tiết hóa đơn long MaHD = hd.MA_HD; long tongtien = 0; foreach (Item item in orders) { CT_HOA_DON cthd = new CT_HOA_DON { MAHD = MaHD, DON_GIA = item.GiaBan, SO_LUONG = item.SoLuongTrongGio, TENSACH = item.TenSach }; tongtien += (item.SoLuongTrongGio * item.GiaBan); db.CT_HOA_DON.Add(cthd); } var updatedHd = db.HOA_DON.FirstOrDefault(x => x.MA_HD == hd.MA_HD); updatedHd.TONG_TIEN = tongtien; db.SaveChanges(); Session.Remove("cart"); return(RedirectToAction("ThankYou", "Cart")); } catch (Exception) { ModelState.AddModelError("", "Đã xảy ra lỗi"); return(View(model)); } }
//tạo tài khoản mới Sign up public bool CreateAcc(NGUOI_DUNG x) { x.BARCODE = acc.RandomString(10); try { db.NGUOI_DUNG.Add(x); db.SaveChanges(); return(true); } catch (Exception) { return(false); } }
public ActionResult ForgotPass(ResetPassVMD model) { if (ModelState.IsValid) { if (acc.CheckResetPass(model.Username, model.Email) == true) { string newpass = db.NGUOI_DUNG.Where(p => p.USERNAME == model.Username).SingleOrDefault().PASSWORD; db.NGUOI_DUNG.Where(p => p.USERNAME == model.Username).SingleOrDefault().PASSWORD = acc.md5(newpass); db.SaveChanges(); string subject = "Rosie Million Store: Reset Password"; string body = "Chào " + model.Username + "Mật khẩu mới của bạn là: " + newpass; acc.SendMail(model.Email, subject, body); return(RedirectToAction("Login", "Login")); } ModelState.AddModelError("", "Thông tin điền vào không hợp lệ"); return(View(model)); } else { ModelState.AddModelError("", "Email, tên đăng nhập không tồn tại."); return(View(model)); } }