public ActionResult Create([Bind(Include = "RoleID,RoleName,Description")] WA_Roles wa_roles) { if (ModelState.IsValid) { db.WA_Roles.Add(wa_roles); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(wa_roles)); }
public ActionResult Create([Bind(Include = "CommentID,ContenComment,PostID,Author,Created,Parent")] WA_Comments wa_comments) { if (ModelState.IsValid) { db.WA_Comments.Add(wa_comments); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.PostID = new SelectList(db.WA_Posts, "PostID", "Title", wa_comments.PostID); ViewBag.Author = new SelectList(db.WA_Users, "UserID", "UserName", wa_comments.Author); return(View(wa_comments)); }
public ActionResult Create([Bind(Include = "PostID,Author,IsLike")] WA_Likes wa_likes) { if (ModelState.IsValid) { db.WA_Likes.Add(wa_likes); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.PostID = new SelectList(db.WA_Posts, "PostID", "Title", wa_likes.PostID); ViewBag.Author = new SelectList(db.WA_Users, "UserID", "UserName", wa_likes.Author); return(View(wa_likes)); }
public ActionResult Create([Bind(Include = "BlogID,Name,Parent,Order,Active")] WA_Blogs wa_blogs) { if (ModelState.IsValid) { db.WA_Blogs.Add(wa_blogs); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(wa_blogs)); }
public JsonResult ChangeTopNav(List <string> listNameTopNav, List <string> listUrlTopNav, List <string> listSocialName, List <string> listSocialUrl) { var list = db.WA_Options.Where(x => x.Group.Equals("Topnav") || x.Group.Equals("TopnavSocical")); db.WA_Options.RemoveRange(list); db.SaveChanges(); var listOptionNav = new List <WA_Options>(); if (listNameTopNav != null) { for (int i = 0; i < listNameTopNav.Count; i++) { string link = listUrlTopNav[i] ?? "#"; if (link.Length > 4 && !link.Substring(0, 4).Equals("http") && link != "#") { link = "http://" + link; } listOptionNav.Add(new WA_Options { Group = "Topnav", Name = listNameTopNav[i], Value = link }); } } if (listSocialName != null) { for (int i = 0; i < listSocialName.Count; i++) { string link = listSocialUrl[i] ?? "#"; if (link.Length > 4 && !link.Substring(0, 4).Equals("http") && link != "#") { link = "http://" + link; } listOptionNav.Add(new WA_Options { Group = "TopnavSocical", Name = listSocialName[i], Value = link }); } } db.WA_Options.AddRange(listOptionNav); db.SaveChanges(); return(Json(listOptionNav, JsonRequestBehavior.AllowGet)); }
public ActionResult QuickEdit([Bind(Include = "PostID,Title,Description,ContentPost,Active")] WA_Posts wa_posts, int[] Blogs, HttpPostedFileBase filebase) { if (ModelState.IsValid) { if (Blogs == null || Blogs.Count() == 0) { return(View("Edit", wa_posts)); } WA_Posts change = db.WA_Posts.Find(wa_posts.PostID); change.Title = wa_posts.Title; change.Description = wa_posts.Description; change.ContentPost = wa_posts.ContentPost; change.Active = wa_posts.Active; change.WA_Blogs = new List <WA_Blogs>(); //Save pic string path = "~/Content/images/thuvien"; if (Request.Files[0] != null) { string tg = DateTime.Now.ToString("ddMMyyyy_"); string pathToSave = Server.MapPath(path); string filename = tg + Path.GetFileName(Request.Files[0].FileName); change.Picture = Path.Combine(path, filename); Request.Files[0].SaveAs(Path.Combine(pathToSave, filename)); } foreach (var item in Blogs) { change.WA_Blogs.Add(db.WA_Blogs.Find(item)); } db.Entry(change).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Author = new SelectList(db.WA_Users, "UserID", "UserName", wa_posts.Author); return(View("Edit", wa_posts)); }
public ActionResult Create([Bind(Include = "UserID,UserName,Email,Password,DisplayName,Created,Modified,Avatar,LastLogin,IPLast,IPCreated")] WA_Users wa_users, HttpPostedFileBase filebase) { if (ModelState.IsValid) { if (Request.Files.Count > 0 || !String.IsNullOrEmpty(Request.Files[0].FileName)) { string path = "~/Content/images/avatar"; string pathToSave = Server.MapPath(path); string filename = Path.GetFileName(Request.Files[0].FileName); Request.Files[0].SaveAs(Path.Combine(pathToSave, filename)); wa_users.Avatar = filename; } db.WA_Users.Add(wa_users); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(wa_users)); }