public ActionResult ThemHinh() { int maloai = int.Parse(Request.Form["maloai"]); int macathe = int.Parse(Request.Form["macathe"]); CaThe model = new G_Shop.Models.CaThe(); if (Session["fileUpload2"] != null) { string _fileName; string listImages = ""; fileUpload = (List <HttpPostedFileBase>)Session["fileUpload2"]; foreach (var item in fileUpload) { string pic = Path.GetFileName(item.FileName).Substring(0, Path.GetFileName(item.FileName).IndexOf(".")); _fileName = pic + ".jpg"; var path = Path.Combine(Server.MapPath("~/assets/client/images/"), _fileName); item.SaveAs(path); listImages += _fileName + "|"; } model = db.CaThes.Where(x => x.MaLoai == maloai && x.MaCaThe == macathe).First(); model.HinhAnh = model.HinhAnh + listImages; db.SaveChanges(); Session["fileUpload"] = null; } return(RedirectToAction("SuaHinh", "AdminHome", new { MaLoai = maloai, MaCaThe = macathe })); }
public ActionResult themGoiY(int C1, int C2) { GoiY g = new GoiY(); g.C1 = C1; g.C2 = C2; db.GoiYs.Add(g); db.SaveChanges(); return(RedirectToAction("CaTheLienQuan", new { MaCaThe = C1 })); }
public bool changePassword(int id, string oldPassword, string newPassword) { NguoiDung nguoiDung = db.NguoiDungs.Find(id); if (nguoiDung.MatKhau == oldPassword) { nguoiDung.MatKhau = newPassword; db.SaveChanges(); return(true); } return(false); }
public JsonResult themgiong(string tengiong, string mota) { try { var giong = new Giong(); giong.TenGiong = tengiong; db.Giongs.Add(giong); db.SaveChanges(); return(Json("ok", JsonRequestBehavior.AllowGet)); } catch { return(Json("error", JsonRequestBehavior.AllowGet)); } }
public JsonResult themloai(string tenloai, string mota) { try { var loai = new Loai(); loai.TenLoai = tenloai; loai.MoTa = mota; db.Loais.Add(loai); db.SaveChanges(); return(Json("ok", JsonRequestBehavior.AllowGet)); } catch { return(Json("error", JsonRequestBehavior.AllowGet)); } }
public ActionResult Checkout(HoaDon order, FormCollection form) { order.TinhTrang = "Mới đặt hàng"; order.GioGiaoHang = Request.Form["gioGiaoHang"] + ":" + Request.Form["phutGiaoHang"] + " " + Request.Form["buoiGiaoHang"]; CultureInfo provider = CultureInfo.InvariantCulture; string format = "dd/MM/yyyy"; order.NgayGiaoHang = DateTime.ParseExact(Request.Form["ngayGiaoHang"], format, provider); //order.NgayGiaoHang = Convert.ToDateTime(form["ngaygiaohang"], ); db.HoaDons.Add(order); // insert order UserDAO userDAO = new UserDAO(); foreach (var p in ShoppingCart.Cart.Items) { var detail = new ChiTietHoaDon { HoaDon = order, MaCaThe = p.MaCaThe, }; userDAO.BanCaThe(p.MaCaThe); db.ChiTietHoaDons.Add(detail); // insert orderdetail } db.SaveChanges(); ShoppingCart.Cart.Clear(); return(RedirectToAction("Detail", "Order", new { id = order.MaHoaDon })); //return RedirectToAction("List", "Order"); }
public JsonResult capnhat(NguoiDungDTO model) { NguoiDung nd = db.NguoiDungs.Find(model.MaNguoiDung); //nd.TenDangNhap = model.TenDangNhap; nd.MatKhau = model.MatKhau; nd.TenNguoiDung = model.TenNguoiDung; nd.DiaChi = model.DiaChi; nd.Email = model.Email; nd.SoDienThoai = model.SoDienThoai; nd.GioiTinh = model.GioiTinh; //nd.NgaySinh = model.NgaySinh; nd.VaiTro = model.VaiTro; db.SaveChanges(); return(Json("ok", JsonRequestBehavior.AllowGet)); }
public ActionResult Register(NguoiDung model) { model.Email = Request.Form["email"]; try { model.VaiTro = "Khách hàng"; db.NguoiDungs.Add(model); db.SaveChanges(); //ModelState.AddModelError("", "Đăng ký thành công. Vui lòng nhận email và kích hoạt tài khoản !"); //var url = Request.Url.AbsoluteUri.Replace("Register", "") + "Activate/" + model.Id.ToBase64(); //var body = @"Click vào liên kết sau để kích hoạt tài khoản: <a href='" + url + "'>Activate</a>"; //XMail.Send(model.Email, "Welcome mail", body); } catch (Exception ex) { ModelState.AddModelError("", "Đăng ký thất bại !" + ex); } return(RedirectToAction("Login", "Account")); }
public void ThemCaThe(CaThe model) { db.CaThes.Add(model); db.SaveChanges(); }