예제 #1
0
 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));
 }
예제 #2
0
        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());
        }
예제 #3
0
 /// <summary>
 /// Xóa bản ghi
 /// </summary>
 public void Delete(DN_Active activeRole)
 {
     FDIDB.DN_Active.Remove(activeRole);
 }
예제 #4
0
 /// <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);
 }
예제 #5
0
 public DN_Active UpdateRole(DN_Active activeRole, ActiveRoleItem activeRoleItem)
 {
     activeRole.NameActive = activeRoleItem.NameActive;
     activeRole.Ord        = activeRoleItem.Ord;
     return(activeRole);
 }
예제 #6
0
        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));
        }