public ActionResult MenuAddSub(FormCollection collection, onsoft.Models.Menu page, string Level) { if (Request.Cookies["Username"] != null) { page.Name = collection["Name"]; if (collection["PageTypeDDL"] == "0") { //Lien ket if (collection["LinkDDL"] == "0") { page.Link = collection["Link"]; } else if (collection["LinkDDL"] == "1") { page.Link = collection["LinkModule"]; } else if (collection["LinkDDL"] == "2") { page.Link = "/san-pham"; } else { page.Link = "/tin-tuc"; } page.IdCategory = null; } else { //Noi dung page.Link = "/gioi-thieu/" + StringClass.NameToTag(collection["Name"].ToString()) + ""; page.IdCategory = 0; } page.Target = collection["Target"]; page.Position = Convert.ToInt32(collection["Position"]); page.Content = collection["Content"]; page.Detail = collection["Detail"]; page.Title = collection["Title"]; page.Description = collection["Description"]; page.Keyword = collection["Keyword"]; page.Ord = Convert.ToInt32(collection["Ord"]); page.Active = (collection["Active"] == "false") ? false : true; page.Tag = onsoft.Models.StringClass.NameToTag(collection["Name"]); page.Level = Level + "00000"; db.Menus.Add(page); db.SaveChanges(); return(RedirectToAction("MenuIndex")); } else { return(RedirectToAction("admins")); } }
public ActionResult MenuEdit(FormCollection collection, onsoft.Models.Menu menu, int id) { if (Request.Cookies["Username"] != null) { var curMenu = db.Menus.Find(id); menu.Name = collection["Name"]; menu.Images = collection["Images"]; menu.Name = menu.Name.Replace(".", ""); menu.Ord = Convert.ToInt32(collection["Ord"]); if (collection["PageTypeDDL"] == "0") { //Lien ket if (collection["LinkDDL"] == "0") { menu.Link = collection["Link"]; } else if (collection["LinkDDL"] == "1") { menu.Link = collection["LinkModule"]; } else if (collection["LinkDDL"] == "2") { menu.Link = "/san-pham"; } else { menu.Link = "/tin-tuc"; } menu.IdCategory = null; } else { //Noi dung menu.Link = "/gioi-thieu/" + StringClass.NameToTag(collection["Name"].ToString()) + ""; menu.IdCategory = 0; } string le = collection["lstMenu"]; menu.Level = le + "00000"; menu.Target = collection["Target"]; menu.Position = Convert.ToInt32(collection["Position"]); menu.Content = collection["Content"]; menu.Detail = collection["Detail"]; menu.Title = collection["Title"]; menu.Description = collection["Description"]; menu.Keyword = collection["Keyword"]; menu.Active = (collection["Active"] == "false") ? false : true; menu.Tag = onsoft.Models.StringClass.NameToTag(collection["Name"]); db.sp_Menu_Update(menu.Id, menu.Name, menu.Tag, menu.IdCategory, menu.Content, menu.Detail, menu.Level, menu.Title, menu.Description, menu.Keyword, menu.Target, menu.Link, menu.Ord, menu.Position, menu.Active, menu.Images); //UpdateModel(menu); //db.Entry(menu).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("MenuIndex")); } else { return(Redirect("/Admins/admins")); } }