public ActionResult Edit(MSlider mSlider) { if (ModelState.IsValid) { String strSlug = XString.ToAscii(mSlider.Name); mSlider.Updated_at = DateTime.Now; mSlider.Updated_by = 1 /*int.Parse(Session["Admin_ID"].ToString());*/; var file = Request.Files["Image"]; if (file != null && file.ContentLength > 0) { String filename = strSlug + file.FileName.Substring(file.FileName.LastIndexOf(".")); mSlider.Image = filename; String Strpath = Path.Combine(Server.MapPath("~/Content/Library/images/Slider/"), filename); file.SaveAs(Strpath); } db.Entry(mSlider).State = EntityState.Modified; db.SaveChanges(); Thongbao.set_flash("Cập nhập thông tin slider thành công!", "success"); return(RedirectToAction("Index")); } return(View(mSlider)); }
public ActionResult Edit(MPost mPost) { if (ModelState.IsValid) { String strSlug = XString.ToAscii(mPost.Title); mPost.Slug = strSlug; mPost.Type = "page"; mPost.Updated_at = DateTime.Now; mPost.Updated_by = int.Parse(Session["Admin_ID"].ToString()); var file = Request.Files["Image"]; if (file != null && file.ContentLength > 0) { String filename = strSlug + file.FileName.Substring(file.FileName.LastIndexOf(".")); mPost.Image = filename; String Strpath = Path.Combine(Server.MapPath("~/Content/Library/images/page/"), filename); file.SaveAs(Strpath); } db.Entry(mPost).State = EntityState.Modified; db.SaveChanges(); Thongbao.set_flash("Đã cập nhật lại nội dung trang đơn!", "success"); return(RedirectToAction("Index")); } return(View(mPost)); }
public ActionResult Edit(MPost mPost) { MTopic mTopic = new MTopic(); ViewBag.ListTopic = new SelectList(db.Topic.ToList(), "ID", "Name", 0); if (ModelState.IsValid) { String strSlug = XString.ToAscii(mPost.Title); mPost.Slug = strSlug; mPost.Type = "post"; mPost.Updated_at = DateTime.Now; mPost.Updated_by = 1 /*int.Parse(Session["Admin_ID"].ToString());*/; var file = Request.Files["Image"]; if (file != null && file.ContentLength > 0) { String filename = strSlug + file.FileName.Substring(file.FileName.LastIndexOf(".")); mPost.Image = filename; String Strpath = Path.Combine(Server.MapPath("~/Content/Path/post/"), filename); file.SaveAs(Strpath); } db.Entry(mPost).State = EntityState.Modified; db.SaveChanges(); Thongbao.set_flash("Đã cập nhật lại bài viết!", "success"); return(RedirectToAction("Index")); } return(View(mPost)); }
public ActionResult Create(MPost mPost) { if (ModelState.IsValid) { String strSlug = XString.ToAscii(mPost.Title); mPost.Slug = strSlug; mPost.Type = "post"; mPost.Created_at = DateTime.Now; mPost.Created_by = 1 /*int.Parse(Session["Admin_ID"].ToString());*/; mPost.Updated_at = DateTime.Now; mPost.Updated_by = 1 /*int.Parse(Session["Admin_ID"].ToString());*/; var file = Request.Files["Image"]; if (file != null && file.ContentLength > 0) { String filename = strSlug + file.FileName.Substring(file.FileName.LastIndexOf(".")); mPost.Image = filename; String Strpath = Path.Combine(Server.MapPath("~/Content/Path/post/"), filename); file.SaveAs(Strpath); } db.Post.Add(mPost); db.SaveChanges(); Thongbao.set_flash("Đã thêm bài viết mới!", "success"); return(RedirectToAction("Index")); } return(View(mPost)); }
public ActionResult Create(MProduct mProduct) { ViewBag.ListCat = new SelectList(db.Category.Where(m => m.Status != 0), "ID", "Name", 0); if (ModelState.IsValid) { mProduct.Price = mProduct.Price; mProduct.ProPrice = mProduct.ProPrice; String strSlug = XString.ToAscii(mProduct.Name); mProduct.Slug = strSlug; mProduct.Created_at = DateTime.Now; mProduct.Created_by = 1; mProduct.Updated_at = DateTime.Now; mProduct.Updated_by = 1; // Upload file var file = Request.Files["Image"]; if (file != null && file.ContentLength > 0) { String filename = strSlug + file.FileName.Substring(file.FileName.LastIndexOf(".")); mProduct.Image = filename; String Strpath = Path.Combine(Server.MapPath("~/Content/Path/product/"), filename); file.SaveAs(Strpath); } db.Product.Add(mProduct); db.SaveChanges(); Thongbao.set_flash("Thêm mới sản phẩm thành công!", "success"); return(RedirectToAction("Index")); } return(View(mProduct)); }
public JsonResult Payment(String Address, String FullName, String Phone, String Email) { var order = new MOrder(); int user_id = Convert.ToInt32(Session["User_ID"]); order.Code = DateTime.Now.ToString("yyyyMMddhhMMss"); // yyyy-MM-dd hh:MM:ss order.UserID = user_id; order.CreateDate = DateTime.Now; order.DeliveryAddress = Address; order.DeliveryEmail = Email; order.DeliveryPhone = Phone; order.DeliveryName = FullName; order.Status = 1; db.Order.Add(order); db.SaveChanges(); var OrderID = order.ID; foreach (var c in (List <ModelCart>)Session["Cart"]) { var orderdetails = new MOrderDetail(); orderdetails.OrderID = OrderID; orderdetails.ProductID = c.ProductID; orderdetails.Price = c.Price; orderdetails.Quantity = c.Quantity; orderdetails.Amount = c.Price * c.Quantity; db.OrderDetail.Add(orderdetails); } db.SaveChanges(); Session.Remove("Cart"); Thongbao.set_flash("Bạn đã đặt hàng thành công!", "success"); return(Json(true)); }
public ActionResult DelTrash(int id) { MCategory MCategory = db.Category.Find(id); if (MCategory == null) { Thongbao.set_flash("Không tồn tại danh mục cần xóa vĩnh viễn!", "warning"); return(RedirectToAction("Index")); } int count_child = db.Category.Where(m => m.ParentID == id).Count(); if (count_child != 0) { Thongbao.set_flash("Không thể xóa, danh mục có chứa danh mục con!", "warning"); return(RedirectToAction("Index")); } MCategory.Status = 0; MCategory.Created_at = DateTime.Now; MCategory.Updated_by = 1 /*int.Parse(Session["Admin_ID"].ToString());*/; MCategory.Updated_at = DateTime.Now; MCategory.Updated_by = 1 /*int.Parse(Session["Admin_ID"].ToString());*/; db.Entry(MCategory).State = EntityState.Modified; db.SaveChanges(); Thongbao.set_flash("Ném thành công vào thùng rác!" + " ID = " + id, "success"); return(RedirectToAction("Index")); }
public ActionResult Create(MCategory MCategory) { ViewBag.listCat = new SelectList(db.Category.Where(m => m.Status == 1), "ID", "Name", 0); ViewBag.listOrder = new SelectList(db.Category.Where(m => m.Status == 1), "Orders", "Name", 0); if (ModelState.IsValid) { if (MCategory.ParentID == null) { MCategory.ParentID = 0; } String Slug = XString.ToAscii(MCategory.Name); CheckSlug check = new CheckSlug(); if (!check.KiemTraSlug("Category", Slug, null)) { Thongbao.set_flash("Tên danh mục đã tồn tại, vui lòng thử lại!", "warning"); return(RedirectToAction("Create", "Category")); } MCategory.Slug = Slug; MCategory.Created_at = DateTime.Now; MCategory.Created_by = 1 /*int.Parse(Session["Admin_ID"].ToString());*/; MCategory.Updated_at = DateTime.Now; MCategory.Updated_by = 1 /*int.Parse(Session["Admin_ID"].ToString());*/; db.Category.Add(MCategory); db.SaveChanges(); Thongbao.set_flash("Danh mục đã được thêm!", "success"); return(RedirectToAction("Index", "Category")); } Thongbao.set_flash("Có lỗi xảy ra khi thêm danh mục!", "warning"); return(View(MCategory)); }
public ActionResult Edit(MProduct mProduct) { ViewBag.ListCat = new SelectList(db.Category.ToList(), "ID", "Name", 0); if (ModelState.IsValid) { String strSlug = XString.ToAscii(mProduct.Name); mProduct.Slug = strSlug; mProduct.Updated_at = DateTime.Now; mProduct.Updated_by = 1; // Upload file var file = Request.Files["Image"]; if (file != null && file.ContentLength > 0) { String filename = strSlug + file.FileName.Substring(file.FileName.LastIndexOf(".")); mProduct.Image = filename; String Strpath = Path.Combine(Server.MapPath("~/Content/Path/product/"), filename); file.SaveAs(Strpath); } db.Entry(mProduct).State = EntityState.Modified; db.SaveChanges(); Thongbao.set_flash("Đã cập nhật lại thông tin sản phẩm!", "success"); return(RedirectToAction("Index")); } return(View(mProduct)); }
public ActionResult DeleteConfirmed(int id) { MMenu mMenu = db.Menu.Find(id); db.Menu.Remove(mMenu); db.SaveChanges(); Thongbao.set_flash("Đã xóa vĩnh viễn menu!", "success"); return(RedirectToAction("Trash")); }
public ActionResult DeleteConfirmed(int id) { MTopic mTopic = db.Topic.Find(id); db.Topic.Remove(mTopic); db.SaveChanges(); Thongbao.set_flash("Đã xóa hoàn toàn chủ đề!", "success"); return(RedirectToAction("Trash", "Topic")); }
public ActionResult DeleteConfirmed(int id) { MOrder mOrder = db.Order.Find(id); db.Order.Remove(mOrder); db.SaveChanges(); Thongbao.set_flash("Đã xóa đơn hàng!", "success"); return(RedirectToAction("Trash")); }
public ActionResult DeleteConfirmed(int id) { MCategory MCategory = db.Category.Find(id); db.Category.Remove(MCategory); db.SaveChanges(); Thongbao.set_flash("Đã xóa hoàn toàn danh mục!", "success"); return(RedirectToAction("Trash", "Category")); }
public ActionResult DeleteConfirmed(int id) { MContact mContact = db.Contact.Find(id); db.Contact.Remove(mContact); db.SaveChanges(); Thongbao.set_flash("Đã xóa vĩnh viễn liên hệ!", "danger"); return(RedirectToAction("Index")); }
public ActionResult DeleteConfirmed(int id) { MSlider mSlider = db.Slider.Find(id); db.Slider.Remove(mSlider); db.SaveChanges(); Thongbao.set_flash("Đã xóa vĩnh viễn slider!", "success"); return(RedirectToAction("Trash")); }
public ActionResult DeleteConfirmed(int id) { MPost mPost = db.Post.Find(id); db.Post.Remove(mPost); db.SaveChanges(); Thongbao.set_flash("Đã xóa vĩnh viễn", "danger"); return(RedirectToAction("Trash")); }
public ActionResult Edit(int?id) { ViewBag.ListCat = new SelectList(db.Category.ToList(), "ID", "Name", 0); MProduct mProduct = db.Product.Find(id); if (mProduct == null) { Thongbao.set_flash("404!", "warning"); return(RedirectToAction("Index", "Product")); } return(View(mProduct)); }
public ActionResult Undo(int?id) { MProduct mProduct = db.Product.Find(id); mProduct.Status = 2; mProduct.Updated_at = DateTime.Now; mProduct.Updated_by = 1; db.Entry(mProduct).State = EntityState.Modified; db.SaveChanges(); Thongbao.set_flash("Khôi phục thành công!" + " ID = " + id, "success"); return(RedirectToAction("Trash")); }
public ActionResult Undo(int?id) { MPost mPost = db.Post.Find(id); mPost.Status = 2; mPost.Updated_at = DateTime.Now; mPost.Updated_by = 1 /*int.Parse(Session["Admin_ID"].ToString());*/; db.Entry(mPost).State = EntityState.Modified; db.SaveChanges(); Thongbao.set_flash("Khôi phục thành công!" + " ID = " + id, "success"); return(RedirectToAction("Trash")); }
public ActionResult DelTrash(int?id) { MProduct mProduct = db.Product.Find(id); mProduct.Status = 0; mProduct.Updated_at = DateTime.Now; mProduct.Updated_by = 1; db.Entry(mProduct).State = EntityState.Modified; db.SaveChanges(); Thongbao.set_flash("Ném thành công vào thùng rác!" + " ID = " + id, "success"); return(RedirectToAction("Index")); }
public ActionResult DelTrash(int?id) { MOrder mOrder = db.Order.Find(id); mOrder.Trash = 1; mOrder.Updated_at = DateTime.Now; mOrder.Updated_by = 1; db.Entry(mOrder).State = EntityState.Modified; db.SaveChanges(); Thongbao.set_flash("Đã hủy đơn hàng!" + " ID = " + id, "success"); return(RedirectToAction("Index")); }
public ActionResult Edit(int?id) { ViewBag.listTopic = new SelectList(db.Topic.Where(m => m.Status == 1), "ID", "Name", 0); ViewBag.listOrder = new SelectList(db.Topic.Where(m => m.Status == 1), "Orders", "Name", 0); MTopic mTopic = db.Topic.Find(id); if (mTopic == null) { Thongbao.set_flash("404!", "warning"); return(RedirectToAction("Index", "Topic")); } return(View(mTopic)); }
public ActionResult Edit(int?id) { ViewBag.listCat = new SelectList(db.Category.Where(m => m.Status == 1), "ID", "Name", 0); ViewBag.listOrder = new SelectList(db.Category.Where(m => m.Status == 1), "Orders", "Name", 0); MCategory MCategory = db.Category.Find(id); if (MCategory == null) { Thongbao.set_flash("404!", "warning"); return(RedirectToAction("Index", "Category")); } return(View(MCategory)); }
public ActionResult Undo(int?id) { MOrder mOrder = db.Order.Find(id); mOrder.Trash = 0; mOrder.Updated_at = DateTime.Now; mOrder.Updated_by = int.Parse(Session["Admin_ID"].ToString()); db.Entry(mOrder).State = EntityState.Modified; db.SaveChanges(); Thongbao.set_flash("Khôi phục thành công!" + " ID = " + id, "success"); return(RedirectToAction("Trash")); }
public ActionResult DelTrash(int?id) { MPost mPost = db.Post.Find(id); mPost.Status = 0; mPost.Updated_at = DateTime.Now; mPost.Updated_by = 1 /*int.Parse(Session["Admin_ID"].ToString());*/; db.Entry(mPost).State = EntityState.Modified; db.SaveChanges(); Thongbao.set_flash("Đã chuyển vào thùng rác!" + " ID = " + id, "success"); return(RedirectToAction("Index")); }
public ActionResult Edit(MTopic mTopic) { ViewBag.listTopic = new SelectList(db.Topic.Where(m => m.Status == 1), "ID", "Name", 0); ViewBag.listOrder = new SelectList(db.Topic.Where(m => m.Status == 1), "Orders", "Name", 0); if (ModelState.IsValid) { if (mTopic.ParentID == null) { mTopic.ParentID = 0; } String Slug = XString.ToAscii(mTopic.Name); int ID = mTopic.ID; if (db.Category.Where(m => m.Slug == Slug && m.ID != ID).Count() > 0) { Thongbao.set_flash("Tên danh mục đã tồn tại, vui lòng thử lại!", "warning"); return(RedirectToAction("Edit", "Topic")); } if (db.Topic.Where(m => m.Slug == Slug && m.ID != ID).Count() > 0) { Thongbao.set_flash("Tên danh mục đã tồn tại trong TOPIC, vui lòng thử lại!", "warning"); return(RedirectToAction("Edit", "Topic")); } if (db.Post.Where(m => m.Slug == Slug && m.ID != ID).Count() > 0) { Thongbao.set_flash("Tên danh mục đã tồn tại trong POST, vui lòng thử lại!", "warning"); return(RedirectToAction("Edit", "Topic")); } if (db.Product.Where(m => m.Slug == Slug && m.ID != ID).Count() > 0) { Thongbao.set_flash("Tên danh mục đã tồn tại trong PRODUCT, vui lòng thử lại!", "warning"); return(RedirectToAction("Edit", "Topic")); } mTopic.Slug = Slug; // Lỗi datatime2 mTopic.Created_at = DateTime.Now; mTopic.Created_by = int.Parse(Session["Admin_ID"].ToString()); mTopic.Updated_at = DateTime.Now; mTopic.Updated_by = int.Parse(Session["Admin_ID"].ToString()); db.Entry(mTopic).State = EntityState.Modified; db.SaveChanges(); Thongbao.set_flash("Câp nhật thành công chủ đề!", "success"); return(RedirectToAction("Index")); } ViewBag.list = db.Category.Where(m => m.Status == 1).ToList(); return(View(mTopic)); }
// Edit public ActionResult Edit(int?id) { MTopic mTopic = new MTopic(); ViewBag.ListTopic = new SelectList(db.Topic.ToList(), "ID", "Name", 0); MPost mPost = db.Post.Find(id); if (mPost == null) { Thongbao.set_flash("Không tồn tại bài viết!", "warning"); return(RedirectToAction("Index", "Post")); } return(View(mPost)); }
//public ActionResult Reply(mContact mContact) //{ // if (ModelState.IsValid) // { // mContact.Status = 2; // mContact.Updated_at = DateTime.Now; // mContact.Updated_by = 1; // String content = System.IO.File.ReadAllText(Server.MapPath("~/Areas/Admin/Views/Mail/D_Mail.html")); // content = content.Replace("{{FullName}}", mContact.Fullname); // content = content.Replace("{{Reply}}", mContact.Reply); // content = content.Replace("{{RQ}}", mContact.Detail); // content = content.Replace("{{AdminName}}", Session["User_Admin"].ToString()); // String subject = "Phản hồi liên hệ từ Giadunghiendai.com"; // //new MailHelper().SendMail(mContact.Email, subject, content); // db.Entry(mContact).State = EntityState.Modified; // db.SaveChanges(); // Thongbao.set_flash("Đã trả lời liên hệ!", "success"); // return RedirectToAction("Index"); // } // return View(mContact); //} public ActionResult Reply(MContact mContact) { if (ModelState.IsValid) { mContact.Flag = 1; mContact.Updated_at = DateTime.Now; mContact.Updated_by = 1 /*int.Parse(Session["Admin_ID"].ToString());*/; db.Entry(mContact).State = EntityState.Modified; db.SaveChanges(); Thongbao.set_flash("Đã trả lời liên hệ!", "success"); return(RedirectToAction("Index")); } return(View(mContact)); }
public ActionResult Create(MTopic mTopic) { ViewBag.listTopic = new SelectList(db.Topic.Where(m => m.Status == 1), "ID", "Name", 0); ViewBag.listOrder = new SelectList(db.Topic.Where(m => m.Status == 1), "Order", "Name", 0); if (ModelState.IsValid) { if (mTopic.ParentID == null) { mTopic.ParentID = 0; } String Slug = XString.ToAscii(mTopic.Name); if (db.Category.Where(m => m.Slug == Slug).Count() > 0) { Thongbao.set_flash("Tên danh mục đã tồn tại, vui lòng thử lại!", "warning"); return(RedirectToAction("Create", "Topic")); } if (db.Topic.Where(m => m.Slug == Slug).Count() > 0) { Thongbao.set_flash("Tên danh mục đã tồn tại trong TOPIC, vui lòng thử lại!", "warning"); return(RedirectToAction("Create", "Topic")); } if (db.Post.Where(m => m.Slug == Slug).Count() > 0) { Thongbao.set_flash("Tên danh mục đã tồn tại trong POST, vui lòng thử lại!", "warning"); return(RedirectToAction("Create", "Topic")); } if (db.Product.Where(m => m.Slug == Slug).Count() > 0) { Thongbao.set_flash("Tên danh mục đã tồn tại trong PRODUCT, vui lòng thử lại!", "warning"); return(RedirectToAction("Create", "Topic")); } mTopic.Slug = Slug; mTopic.Created_at = DateTime.Now; mTopic.Created_by = int.Parse(Session["Admin_ID"].ToString()); mTopic.Updated_at = DateTime.Now; mTopic.Updated_by = int.Parse(Session["Admin_ID"].ToString()); db.Topic.Add(mTopic); db.SaveChanges(); Thongbao.set_flash("Danh mục đã được thêm!", "success"); return(RedirectToAction("Index", "Topic")); } ViewBag.list = db.Category.Where(m => m.Status == 1).ToList(); Thongbao.set_flash("Có lỗi xảy ra khi thêm danh mục!", "warning"); return(View(mTopic)); }
public ActionResult Edit(int?id) { if (id == null) { Thongbao.set_flash("Không tồn tại!", "warning"); return(RedirectToAction("Index")); } MSlider mSlider = db.Slider.Find(id); if (mSlider == null) { Thongbao.set_flash("Không tồn tại!", "warning"); return(RedirectToAction("Index")); } return(View(mSlider)); }