public ActionResult AjaxForm() { var tagModel = new System_Tag(); if (DoAction == ActionType.Edit) { tagModel = _tagDa.GetById(ArrId.FirstOrDefault()); } ViewData.Model = tagModel; ViewBag.Action = DoAction; ViewBag.ActionText = ActionText; return(View()); }
public System_Tag AddOrGet(string tagName) { var systemTag = GetByName(tagName); if (systemTag == null) { var newTag = new System_Tag { Name = tagName }; FDIDB.System_Tag.Add(newTag); FDIDB.SaveChanges(); return(newTag); } return(systemTag); }
public void Delete(System_Tag systemTag) { FDIDB.System_Tag.Remove(systemTag); }
public void Add(System_Tag systemTag) { FDIDB.System_Tag.Add(systemTag); }
public ActionResult Actions() { var msg = new JsonMessage(); var tag = new System_Tag(); List <System_Tag> ltsTagItems; StringBuilder stbMessage; switch (DoAction) { case ActionType.Add: UpdateModel(tag); tag.LanguageId = Fdisystem.LanguageId; tag.NameAscii = FomatString.Slug(tag.Name); tag.IsDelete = false; tag.IsShow = true; _tagDa.Add(tag); _tagDa.Save(); msg = new JsonMessage { Erros = false, ID = tag.ID.ToString(), Message = string.Format("Đã thêm mới từ khóa: <b>{0}</b>", Server.HtmlEncode(tag.Name)) }; break; case ActionType.Edit: tag = _tagDa.GetById(ArrId.FirstOrDefault()); UpdateModel(tag); tag.NameAscii = FomatString.Slug(tag.Name); _tagDa.Save(); msg = new JsonMessage { Erros = false, ID = tag.ID.ToString(), Message = string.Format("Đã cập nhật từ khóa: <b>{0}</b>", Server.HtmlEncode(tag.Name)) }; break; case ActionType.Delete: ltsTagItems = _tagDa.GetListByArrId(ArrId); stbMessage = new StringBuilder(); foreach (var item in ltsTagItems) { item.IsDelete = true; stbMessage.AppendFormat("Đã xóa từ khóa <b>{0}</b>.<br />", Server.HtmlEncode(item.Name)); } msg.ID = string.Join(",", ArrId); _tagDa.Save(); msg.Message = stbMessage.ToString(); break; case ActionType.Show: ltsTagItems = _tagDa.GetListByArrId(ArrId); stbMessage = new StringBuilder(); foreach (var item in ltsTagItems) { item.IsShow = true; stbMessage.AppendFormat("Đã hiển thị từ khóa <b>{0}</b>.<br />", Server.HtmlEncode(item.Name)); } _tagDa.Save(); msg.ID = string.Join(",", ltsTagItems.Select(o => o.ID)); msg.Message = stbMessage.ToString(); break; case ActionType.Hide: ltsTagItems = _tagDa.GetListByArrId(ArrId); stbMessage = new StringBuilder(); foreach (var item in ltsTagItems) { item.IsShow = false; stbMessage.AppendFormat("Đã ẩn từ khóa <b>{0}</b>.<br />", Server.HtmlEncode(item.Name)); } _tagDa.Save(); msg.ID = string.Join(",", ltsTagItems.Select(o => o.ID)); msg.Message = stbMessage.ToString(); break; } if (string.IsNullOrEmpty(msg.Message)) { msg.Message = "Không có hành động nào được thực hiện."; msg.Erros = true; } return(Json(msg, JsonRequestBehavior.AllowGet)); }