public ActionResult Edit([Bind(Include = "BlogID,BlogName,ImageURL,Descript,Content,TypeBlog,Sort,CountView,IsActive,CategoryID,SEOTitle,SEOUrlRewrite,SEOKeywords,SEOMetadescription")] Blog blog, HttpPostedFileBase HinhAnh) { if (ModelState.IsValid) { var allowedExtensions = new[] { ".Jpg", ".png", ".jpg", "jpeg" }; if (HinhAnh == null) { blog.ImageURL = "NoImage.png"; } else { //Xóa hình ảnh đã tồn tại, trừ hình ảnh mặc định. if (blog.ImageURL != "NoImage.png") { string fullPath = Request.MapPath(WebConstants.imgNewsURL + "/" + blog.ImageURL); if (System.IO.File.Exists(fullPath)) { System.IO.File.Delete(fullPath); } } var fileName = Path.GetFileName(HinhAnh.FileName); var ext = Path.GetExtension(HinhAnh.FileName); if (allowedExtensions.Contains(ext)) //check what type of extension { string name = Path.GetFileNameWithoutExtension(fileName); //getting file name without extension string myfile = name + "_" + DateTime.Now.Millisecond + ext; //appending the name with id // store the file inside ~/project folder(Img) var path = Path.Combine(Server.MapPath(WebConstants.imgNewsURL), myfile); //var dir = Directory.CreateDirectory(path); //HinhAnh.SaveAs(Path.Combine(path, myfile)); blog.ImageURL = myfile; HinhAnh.SaveAs(path); } else { ViewBag.message = "Please choose only Image file"; } } //blog.TypeBlog = WebConstants.BlogAboutUs; blog.SEOUrlRewrite = Helpers.ConvertToUpperLower(blog.BlogName); blog.CreatedBy = db.Users.FirstOrDefault(q => q.UserName == User.Identity.Name).UserID; blog.Created = DateTime.Now; blog.LastModify = DateTime.Now; db.Entry(blog).State = EntityState.Modified; db.SaveChanges(); Success(string.Format("Chỉnh sửa thông tin <b>{0}</b> thành công.", ""), true); return(RedirectToAction("Index")); } ViewBag.CategoryID = new SelectList(db.Categories.Where(c => c.TypeCate == WebConstants.CategoryAboutUs), "CategoryID", "CategoryName", blog.CategoryID); ViewBag.CreatedBy = new SelectList(db.Users, "UserID", "UserName", blog.CreatedBy); return(View(blog)); }
public ActionResult Edit([Bind(Include = "Id,LibraryName,LibraryDesc,Created")] PhotoLibraryCategory photoLibraryCategory) { if (ModelState.IsValid) { db.Entry(photoLibraryCategory).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(photoLibraryCategory)); }
public ActionResult Edit([Bind(Include = "Id,Question,Answer,IsActive,ThuTu,Created,LastModify")] Q_A q_A) { if (ModelState.IsValid) { db.Entry(q_A).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(q_A)); }
public ActionResult Edit([Bind(Include = "UserID,UserName,HashPass,Active,Created,CreatedBy")] User user) { if (ModelState.IsValid) { db.Entry(user).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CreatedBy = new SelectList(db.Users, "UserID", "UserName", user.CreatedBy); return(View(user)); }
public ActionResult Edit([Bind(Include = "SlideID,ImageURL,Slogun1,Slogun2,SlideTitle,LinkBanner,LinkTarget,CategoryID,IsActive,Sort,Created,CreateBy")] Slide slide) { if (ModelState.IsValid) { db.Entry(slide).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CreateBy = new SelectList(db.Users, "UserID", "UserName", slide.CreateBy); return(View(slide)); }
public ActionResult Edit([Bind(Include = "Id,CarCode,CustID,AddresDelivery,CustPhone,TimeDelivery,ShipDelivery,Qty,Total,VouchersCode,VourcerMoney,TotalConLai,Notes,StatusOrder,StyleShip,Created,Updated")] Cart cart) { if (ModelState.IsValid) { db.Entry(cart).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CustID = new SelectList(db.CustomerOrders, "Id", "CustName", cart.CustID); return(View(cart)); }
public ActionResult Edit([Bind(Include = "CustomerContactID,CustomerName,CustomerEmail,CustomerPhone,CustomerAddress,CustomerContent,ContactTypeId,StatusReply,DateReply,AdminNote,Created")] CustomerContact customerContact) { if (ModelState.IsValid) { customerContact.DateReply = DateTime.Now; db.Entry(customerContact).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ContactTypeId = new SelectList(db.CustomerContactTypes, "Id", "TypeName", customerContact.ContactTypeId); return(View(customerContact)); }
public ActionResult Edit([Bind(Include = "CategoryID,CategoryName,Parent,DisplayMenu,IsActive,Sort,SEOTitle,SEOUrlRewrite,SEOKeywords,SEOMetadescription")] Category category) { if (ModelState.IsValid) { category.TypeCate = WebConstants.CategoryNews; category.SEOUrlRewrite = Helpers.ConvertToUpperLower(category.CategoryName); db.Entry(category).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(category)); }
public ActionResult Edit([Bind(Include = "CustomerID,CustomerName,CustomerImage,CustomerContent,IsActive,Created")] Customer customer, HttpPostedFileBase HinhAnh) { if (ModelState.IsValid) { var allowedExtensions = new[] { ".Jpg", ".png", ".jpg", "jpeg" }; if (HinhAnh == null) { customer.CustomerImage = customer.CustomerImage; } else { //Xóa hình ảnh đã tồn tại, trừ hình ảnh mặc định. if (customer.CustomerImage != "NoImage.png") { string fullPath = Request.MapPath(WebConstants.imgLogoCust + "/" + customer.CustomerImage); if (System.IO.File.Exists(fullPath)) { System.IO.File.Delete(fullPath); } } var fileName = Path.GetFileName(HinhAnh.FileName); var ext = Path.GetExtension(HinhAnh.FileName); if (allowedExtensions.Contains(ext)) //check what type of extension { string name = Path.GetFileNameWithoutExtension(fileName); //getting file name without extension string myfile = name + "_" + DateTime.Now.Millisecond + ext; //appending the name with id // store the file inside ~/project folder(Img) var path = Path.Combine(Server.MapPath(WebConstants.imgLogoCust), myfile); //var dir = Directory.CreateDirectory(path); //HinhAnh.SaveAs(Path.Combine(path, myfile)); customer.CustomerImage = myfile; HinhAnh.SaveAs(path); } else { ViewBag.message = "Please choose only Image file"; } } db.Entry(customer).State = EntityState.Modified; Success(string.Format("sửa thông tin <b>{0}</b> thành công.", customer.CustomerName), true); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(customer)); }
public ActionResult Edit([Bind(Include = "CategoryID,CategoryName,Parent,DisplayMenu,IsActive,Sort,TypeCate,SEOTitle,SEOUrlRewrite,SEOKeywords,SEOMetadescription")] Category category) { if (ModelState.IsValid) { category.TypeCate = WebConstants.CategoryProduct; category.SEOUrlRewrite = Helpers.ConvertToUpperLower(category.CategoryName); db.Entry(category).State = EntityState.Modified; db.SaveChanges(); Success(string.Format("Sửa <b>{0}</b> thành công. <b>{0}</b>.", category.CategoryName), true); //return RedirectToAction("Index"); return(RedirectToAction("Index", "Categories", new { Area = "Quantri" })); } return(View(category)); }
public ActionResult Edit([Bind(Include = "Id,CustomerName,CustomerImage,CustomerInfo,Feedback,ThuTu,IsActive,Created,LastModify")] CustomerFeedback customerFeedback, HttpPostedFileBase HinhAnh) { if (ModelState.IsValid) { var allowedExtensions = new[] { ".Jpg", ".png", ".jpg", "jpeg" }; if (HinhAnh == null) { customerFeedback.CustomerImage = customerFeedback.CustomerImage; } else { var fileName = Path.GetFileName(HinhAnh.FileName); var ext = Path.GetExtension(HinhAnh.FileName); if (allowedExtensions.Contains(ext)) //check what type of extension { string name = Path.GetFileNameWithoutExtension(fileName); //getting file name without extension string myfile = name + "_" + DateTime.Now.Millisecond + ext; //appending the name with id // store the file inside ~/project folder(Img) var path = Path.Combine(Server.MapPath(WebConstants.imgCusFeedback), myfile); //var dir = Directory.CreateDirectory(path); //HinhAnh.SaveAs(Path.Combine(path, myfile)); customerFeedback.CustomerImage = myfile; HinhAnh.SaveAs(path); } else { ViewBag.message = "Please choose only Image file"; } } customerFeedback.Created = customerFeedback.Created; customerFeedback.LastModify = DateTime.Now; db.Entry(customerFeedback).State = EntityState.Modified; db.SaveChanges(); Success(string.Format("Chỉnh sửa Phản hồi thành công.", ""), true); return(RedirectToAction("Index", "CustomerFeedbacks")); } return(View(customerFeedback)); }
public ActionResult Details(int?id) { if (id == null) { return(View("NotFound", "Home")); } ProjectViewModel model = new ProjectViewModel(); model.detail = db.Products.Where(p => p.IsActive == true && p.IsProduct == false && p.ProductID == id).FirstOrDefault(); model.detail.CountView = model.detail.CountView + 1; db.Entry(model.detail).State = EntityState.Modified; db.SaveChanges(); model.lstCategory = db.Categories.Where(c => c.IsActive == true && c.TypeCate == WebConstants.CategoryProduct).ToList(); model.lstImages = db.ProductImages.Where(i => i.ProductID == id).ToList(); var cateid = db.Products.Where(p => p.IsActive == true && p.IsProduct == false && p.ProductID == id).FirstOrDefault().CategoryID; model.lstProjects1 = db.Products.Where(p => p.IsActive == true && p.IsProduct == false && p.CategoryID == cateid && p.ProductID != id).OrderByDescending(p => p.ProductID).Take(4).ToList(); return(View(model)); }
public ActionResult Edit([Bind(Include = "ProductID,ProductCode,ProductName,Price,PriceSale,CategoryIDParent,CategoryID,Images,ImagesThumb,ShortDescription,Content,InStock,IsSale,IsNew,Rating,IsActive,CountView,Created,CreatedBy,SEOTitle,SEOUrlRewrite,SEOKeywords,SEOMetadescription")] Product product, HttpPostedFileBase HinhAnh) { if (ModelState.IsValid) { var allowedExtensions = new[] { ".Jpg", ".png", ".jpg", "jpeg" }; if (HinhAnh == null) { product.Images = product.Images; } else { //Xóa hình ảnh đã tồn tại, trừ hình ảnh mặc định. if (product.Images != "NoImage.png") { string fullPath = Request.MapPath(WebConstants.ImgProduct + "/" + product.Images); if (System.IO.File.Exists(fullPath)) { System.IO.File.Delete(fullPath); } } var fileName = Path.GetFileName(HinhAnh.FileName); var ext = Path.GetExtension(HinhAnh.FileName); if (allowedExtensions.Contains(ext)) //check what type of extension { string name = Path.GetFileNameWithoutExtension(fileName); //getting file name without extension string myfile = "du-an" + name + "_" + DateTime.Now.Millisecond + ext; //appending the name with id // store the file inside ~/project folder(Img) var path = Path.Combine(Server.MapPath(WebConstants.ImgProduct), myfile); //var dir = Directory.CreateDirectory(path); //HinhAnh.SaveAs(Path.Combine(path, myfile)); product.Images = myfile; HinhAnh.SaveAs(path); } else { ViewBag.message = "Please choose only Image file"; } } product.IsProduct = false; product.Price = product.Price; product.PriceSale = product.PriceSale; product.Created = product.Created; product.CreatedBy = product.CreatedBy; product.SEOUrlRewrite = Helpers.ConvertToUpperLower(product.ProductName); db.Entry(product).State = EntityState.Modified; db.SaveChanges(); Success(string.Format("Chỉnh sửa thông tin Bộ sưu tập <b>{0}</b> thành công.", product.ProductName), true); return(RedirectToAction("Details", "Collections", new { id = product.ProductID })); } ViewBag.CategoryIDParent = new SelectList(db.Categories.Where(c => c.TypeCate == WebConstants.CategoryCollection), "CategoryID", "CategoryName", product.CategoryIDParent); ViewBag.CategoryID = new SelectList(db.Categories, "CategoryID", "CategoryName", product.CategoryID); ViewBag.CreatedBy = new SelectList(db.Users, "UserID", "UserName", product.CreatedBy); Success(string.Format("Chỉnh sửa thông tin Bộ sưu tập <b>{0}</b> thành công.", product.ProductName), true); return(RedirectToAction("Details", "Collections", new { id = product.ProductID })); }