public ActionResult Create([Bind(Include = "Id,name,meta,img")] banner banner, HttpPostedFileBase img) { var path = ""; var filename = ""; if (ModelState.IsValid) { if (img != null) { filename = img.FileName; path = Path.Combine(Server.MapPath("~/Content/images"), filename); img.SaveAs(path); banner.img = filename; } else { banner.img = "logo.png"; } banner.meta = Functions.ConvertToUnSign(banner.name); db.banners.Add(banner); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(banner)); }
public ActionResult Edit([Bind(Include = "ID,NgayTao,TenKH,DienThoai,DiaChi,Email,TrangThai")] Order order) { if (ModelState.IsValid) { db.Entry(order).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(order)); }
public ActionResult Create([Bind(Include = "id,name,link,meta,hide,order,datebegin")] Category category) { if (ModelState.IsValid) { db.Categories.Add(category); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(category)); }
public ActionResult Create([Bind(Include = "id,name,link,meta,hide,order,datebegin")] Menu menu) { if (ModelState.IsValid) { db.Menus.Add(menu); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(menu)); }
public ActionResult Create([Bind(Include = "ID,Name,Phone,Email,Address,Content,CreatedDate,Status")] Feedback2 feedback2) { if (ModelState.IsValid) { db.Feedback2.Add(feedback2); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(feedback2)); }
public JsonResult SaveData(User model) { model.IsValid = false; db.Users.Add(model); db.SaveChanges(); // BuildEmailTemplate(model.ID); return(Json("Registration Successfull", JsonRequestBehavior.AllowGet)); }
public bool Insert(OrderDetail detail) { try { db.OrderDetails.Add(detail); db.SaveChanges(); return(true); } catch { return(false); } }
public ActionResult Create([Bind(Include = "id,name,price,img,description,meta,size,color,hide,order,datebegin,categoryid")] Product product, HttpPostedFileBase img) { try { var path = ""; var filename = ""; if (ModelState.IsValid) { if (img != null) { //filename = Guid.NewGuid().ToString() + img.FileName; filename = DateTime.Now.ToString("dd-MM-yy-hh-mm-ss-") + img.FileName; path = Path.Combine(Server.MapPath("~/Content/upload/img/product"), filename); img.SaveAs(path); product.img = filename; //Lưu ý } else { product.img = "logo.png"; } product.datebegin = Convert.ToDateTime(DateTime.Now.ToShortDateString()); product.meta = Functions.ConvertToUnSign(product.meta); //convert Tiếng Việt không dấu product.order = getMaxOrder(product.categoryid); db.Products.Add(product); db.SaveChanges(); //return RedirectToAction("Index"); return(RedirectToAction("Index", "Products", new { id = product.categoryid })); } } catch (DbEntityValidationException e) { throw e; } catch (Exception ex) { throw ex; } return(View(product)); }
public ActionResult Create([Bind(Include = "id,name,img,description,link,detaik,meta,hide,order,datebegin")] News news, HttpPostedFileBase img) { try { var path = ""; var filename = ""; if (ModelState.IsValid) { if (img != null) { //filename = Guid.NewGuid().ToString() + img.FileName; filename = img.FileName; path = Path.Combine(Server.MapPath("~/Content/upload/img/news"), filename); img.SaveAs(path); news.img = filename; //Lưu ý } else { news.img = "logo.png"; } news.datebegin = Convert.ToDateTime(DateTime.Now.ToShortDateString()); news.meta = Functions.ConvertToUnSign(news.name); db.News.Add(news); db.SaveChanges(); return(RedirectToAction("Index")); } } catch (DbEntityValidationException e) { throw e; } catch (Exception ex) { throw ex; } return(View(news)); }
public int InsertFeedBack(Feedback2 fb) { db.Feedback2.Add(fb); db.SaveChanges(); return(fb.ID); }
public int Insert(Order order) { db.Orders.Add(order); db.SaveChanges(); return(order.ID); }