Example #1
0
        /// <summary>
        /// 编辑
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Edit(int id)
        {
            FunctionalAuthority dpt =
                BusinessContext.FunctionalAuthority.Get(Query <FunctionalAuthority> .EQ(t => t.Rid, id));

            if (dpt == null)
            {
                return(HttpNotFound());
            }
            return(View(dpt));
        }
Example #2
0
        public ActionResult Edit(FunctionalAuthority collection)
        {
            ReturnMessage RM = new ReturnMessage(false);

            if (ModelState.IsValid)
            {
                try
                {
                    FunctionalAuthority old = BusinessContext.FunctionalAuthority.Get(Query <FunctionalAuthority> .EQ(t => t.Rid, collection.Rid));
                    RM.IsSuccess = BusinessContext.FunctionalAuthority.Update(collection);
                    if (RM.IsSuccess)
                    {
                        OperateLogHelper.Edit(collection, old);
                    }
                }
                catch (Exception ex)
                {
                    RM.Message = ex.Message;
                }
            }
            return(Json(RM));
        }
Example #3
0
        public ActionResult Create(FunctionalAuthority obj, string IsContinue = "0")
        {
            ReturnMessage RM = new ReturnMessage(false);

            if (ModelState.IsValid)
            {
                try
                {
                    //var list = BusinessContext.FunctionalAuthority.GetList("Module_Name ='" + obj.Module_Name + "'");
                    List <FunctionalAuthority> list =
                        BusinessContext.FunctionalAuthority.GetList(Query <FunctionalAuthority> .EQ(t => t.Module_Name,
                                                                                                    obj.Module_Name));
                    //var list = BusinessContext.FunctionalAuthority.Where(p => p.Module_Name == obj.Module_Name).ToList();
                    if (list != null && list.Count() > 0)
                    {
                        obj.Module_Id = list.First().Module_Id;
                        var group = list.FirstOrDefault(p => p.Group_Name == obj.Group_Name);
                        var right = list.FirstOrDefault(p => p.Right_Name == obj.Right_Name);
                        if (right != null)
                        {
                            RM.Message = "页面名称重复";
                            return(Json(RM));
                        }
                        if (group == null)
                        {
                            obj.Group_Id = list.Max(p => p.Group_Id) + 1;
                            obj.Right_Id = 1;
                        }
                        else
                        {
                            obj.Group_Id = group.Group_Id;
                            obj.Right_Id = Convert.ToInt32(list.Where(p => p.Group_Id == obj.Group_Id).Max(p => p.Right_Id)) + 1;
                        }
                    }
                    else
                    {
                        int maxModule = Convert.ToInt32(BusinessContext.FunctionalAuthority.GetMaxId());
                        obj.Module_Id = maxModule + 1;
                        obj.Group_Id  = 1;
                        obj.Right_Id  = 1;
                    }
                    bool res = BusinessContext.FunctionalAuthority.Add(obj);
                    RM.IsSuccess = res;
                    if (RM.IsSuccess)
                    {
                        //obj.Rid = Rid;
                        OperateLogHelper.Create(obj);
                        if (IsContinue == "1")
                        {
                            RM.IsContinue = true;
                        }
                        else
                        {
                            RM.IsContinue = false;
                        }
                    }
                }
                catch (Exception ex)
                {
                    RM.Message = ex.Message;
                }
            }

            return(Json(RM));
        }