public ActionResult Add(string key, ActiveRoleItem activeRole) { if (key == Keyapi) { var obj = new DN_Active(); UpdateRole(obj, activeRole); _dl.Save(); _dl.Add(obj); return(Json(1, JsonRequestBehavior.AllowGet)); } return(Json(0, JsonRequestBehavior.AllowGet)); }
public ActionResult AjaxForm() { var activeRole = new DN_Active(); if (DoAction == ActionType.Edit) { activeRole = _dnActiveRoleDa.GetById(ArrId.FirstOrDefault()); } ViewData.Model = activeRole; ViewBag.Action = DoAction; ViewBag.ActionText = ActionText; return(View()); }
/// <summary> /// Xóa bản ghi /// </summary> public void Delete(DN_Active activeRole) { FDIDB.DN_Active.Remove(activeRole); }
/// <summary> /// Thêm mới bản ghi /// </summary> /// <param name="activeRole">bản ghi cần thêm</param> public void Add(DN_Active activeRole) { FDIDB.DN_Active.Add(activeRole); }
public DN_Active UpdateRole(DN_Active activeRole, ActiveRoleItem activeRoleItem) { activeRole.NameActive = activeRoleItem.NameActive; activeRole.Ord = activeRoleItem.Ord; return(activeRole); }
public ActionResult Actions() { var msg = new JsonMessage(); var activeRole = new DN_Active(); switch (DoAction) { case ActionType.Add: try { UpdateModel(activeRole); _dnActiveRoleDa.Add(activeRole); _dnActiveRoleDa.Save(); msg = new JsonMessage { Erros = false, ID = activeRole.ID.ToString(), Message = string.Format("Đã thêm mới hành động: <b>{0}</b>", Server.HtmlEncode(activeRole.NameActive)) }; } catch (Exception ex) { LogHelper.Instance.LogError(GetType(), ex); } break; case ActionType.Edit: try { activeRole = _dnActiveRoleDa.GetById(ArrId.FirstOrDefault()); UpdateModel(activeRole); _dnActiveRoleDa.Save(); msg = new JsonMessage { Erros = false, ID = activeRole.ID.ToString(), Message = string.Format("Đã cập nhật chuyên mục: <b>{0}</b>", Server.HtmlEncode(activeRole.NameActive)) }; } catch (Exception ex) { LogHelper.Instance.LogError(GetType(), ex); } break; case ActionType.Delete: var ltsRolesItems = _dnActiveRoleDa.GetListByArrID(ArrId); var stbMessage = new StringBuilder(); foreach (var item in ltsRolesItems) { _dnActiveRoleDa.Delete(item); stbMessage.AppendFormat("Đã xóa chuyên mục <b>{0}</b>.<br />", Server.HtmlEncode(item.NameActive)); } msg.ID = string.Join(",", ArrId); _dnActiveRoleDa.Save(); 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)); }