Exemple #1
0
        public AuthorUIModel GetAuthorById(int authorid)
        {
            using (var db = new EFContext())
            {
                AuthorUIModel author = (from s in db.SysAuthors.AsNoTracking()
                                        where s.AuthorId == authorid
                                        select new AuthorUIModel()
                {
                    ActionNameUIModel = s.ActionName,
                    AuthorGuidUIModel = s.AuthorGuid,
                    AuthorIdUIModel = s.AuthorId,
                    AuthorNameUIModel = s.AuthorName,
                    AuthorPathUIModel = s.AuthorPath,
                    ControllerNameUIModel = s.ControllerName,
                    ParentGuidUIModel = s.ParentGuid,
                    AuthorTypeUIModel = s.AuthorType,
                    AuthorDesUIModel = s.AuthorDes,
                }).FirstOrDefault();



                if (author == null)
                {
                    throw new Exception("要编辑的权限信息不存在,请您刷新以后在操作!");
                }
                else
                {
                    if (author.AuthorTypeUIModel == "其他权限")
                    {
                        author.AuthorTypeUIModel = "10";
                    }
                    else if (author.AuthorTypeUIModel == "页面权限")
                    {
                        author.AuthorTypeUIModel = "20";
                    }
                    else if (author.AuthorTypeUIModel == "操作权限")
                    {
                        author.AuthorTypeUIModel = "30";
                    }
                }
                return(author);
            }
        }
        public ActionResult UpdateInit(int authorid)
        {
            JsonResultData <AuthorUIModel> resultdata = new JsonResultData <AuthorUIModel>();

            try
            {
                AuthorUIModel author = authorservice.GetAuthorById(authorid);
                resultdata.Data = author;
                if (author == null)
                {
                    resultdata.Code = 0;
                }
                else
                {
                    resultdata.Code = 1;
                }
            }
            catch (Exception ex)
            {
                resultdata.Msg = ex.Message;
            }

            return(Json(resultdata, JsonRequestBehavior.AllowGet));
        }