Beispiel #1
0
        public async Task <ActionResult> Update([FromBody] SysUserView model)
        {
            var resdata = await AutoException.Excute <SysUser>(async (result) =>
            {
                model.UpdateBy = "admin";
                model.UpdateDt = DateTime.Now;
                var res        = await SysUserDAL.UpdateAsync(model);
                result.Data    = model;
                if (!res)
                {
                    throw new Exception("数据修改异常,JSON:" + Newtonsoft.Json.JsonConvert.SerializeObject(model));
                }
                else
                {
                    if (!string.IsNullOrEmpty(model.userrole))
                    {
                        string[] idstr = model.userrole.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                        List <SysUserRole> rolelist = (from p in idstr
                                                       select new SysUserRole
                        {
                            RoleId = Convert.ToInt32(p),
                            UserId = model.Id,
                            Status = 1,
                            CreateDt = DateTime.Now,
                            CreateBy = model.UpdateBy
                        }).ToList();
                        await SysUserRoleDAL.BatchInsertAsync(rolelist);
                    }
                }
            }, false);

            return(Json(resdata));
        }
Beispiel #2
0
        public async Task <ActionResult> Create([FromBody] SysMenuView model)
        {
            var resdata = await AutoException.Excute <long>(async (result) =>
            {
                model.CreateBy = "admin";
                model.CreateDt = DateTime.Now;
                model.ParentID = model.ParentID == null ? 0 : model.ParentID;
                result.Data    = await new SysMenuDAL().InsertAsync(model);
                if (result.Data == 0)
                {
                    throw new Exception("数据新增异常,JSON:" + Newtonsoft.Json.JsonConvert.SerializeObject(model));
                }
                else
                {
                    if (!string.IsNullOrEmpty(model.menubuttons))
                    {
                        var idstr = Newtonsoft.Json.JsonConvert.DeserializeObject <List <dynamic> >(model.menubuttons);
                        List <SysMenuButton> rolelist = (from p in idstr
                                                         select new SysMenuButton
                        {
                            MenuID = result.Data,
                            ButtonCode = p.id,
                            ButtonName = p.title,
                            Status = 1,
                            CreateDt = DateTime.Now,
                            CreateBy = model.UpdateBy
                        }).ToList();
                        await SysMenuButtonDAL.BatchInsertAsync(rolelist);
                    }
                }
            }, false);

            return(Json(resdata));
        }
Beispiel #3
0
        public async Task <ActionResult> Create([FromBody] SysRoleView model)
        {
            var resdata = await AutoException.Excute <long>(async (result) =>
            {
                model.CreateBy = "admin";
                model.CreateDt = DateTime.Now;
                result.Data    = await SysRoleDAL.InsertAsync(model);
                if (result.Data == 0)
                {
                    throw new Exception("数据新增异常,JSON:" + Newtonsoft.Json.JsonConvert.SerializeObject(model));
                }
                else
                {
                    if (!string.IsNullOrEmpty(model.authids))
                    {
                        string[] idstr = model.authids.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                        List <SysRoleMenu> rolelist = (from p in idstr
                                                       select new SysRoleMenu
                        {
                            RoleId = Convert.ToInt32(result.Data),
                            MenuId = Convert.ToInt32(p),
                            Status = 1,
                            CreateDt = DateTime.Now,
                            CreateBy = model.UpdateBy
                        }).ToList();
                        await SysRoleMenuDAL.BatchInsertAsync(rolelist);
                    }
                }
            }, false);

            return(Json(resdata));
        }
Beispiel #4
0
        public ActionResult SyncData()
        {
            var resdata = AutoException.Execute((result) =>
            {
                new Common.Help.ReadWikiHepler().WikiToArticle();
                result.Status = 1;
            }, false);

            return(Json(resdata));
        }
        //[ValidateAntiForgeryToken]
        public ActionResult DocTypeDelete(int id, IFormCollection collection)
        {
            var resdata = AutoException.Excute <long>((result) =>
            {
                if (!DocumentTypeDAL.Delete(id))
                {
                    throw new Exception("数据删除异常,ID:" + id);
                }
            }, false);

            return(Json(resdata));
        }
        //[ValidateAntiForgeryToken]
        public ActionResult DocContentCreate([FromBody] DocumentContent model)
        {
            var resdata = AutoException.Excute <long>((result) =>
            {
                result.Data = DocumentContentDAL.Insert(model);
                if (result.Data == 0)
                {
                    throw new Exception("数据新增异常,JSON:" + Newtonsoft.Json.JsonConvert.SerializeObject(model));
                }
            }, false);

            return(Json(resdata));
        }
Beispiel #7
0
        public async Task <ActionResult> Update([FromBody] SiteInfo model)
        {
            var resdata = await AutoException.Excute <SiteInfo>(async (result) =>
            {
                model.Status = 1;
                var res      = await SiteInfoDAL.UpdateAsync(model);
                result.Data  = model;
                if (!res)
                {
                    throw new Exception("数据修改异常,JSON:" + Newtonsoft.Json.JsonConvert.SerializeObject(model));
                }
            }, false);

            return(Json(resdata));
        }
Beispiel #8
0
        public async Task <ActionResult> Create([FromBody] ArticleContent model)
        {
            var resdata = await AutoException.Excute <long>(async (result) =>
            {
                model.CreateBy = "admin";
                model.CreateDt = DateTime.Now;
                result.Data    = await ArticleContentDAL.InsertAsync(model);
                if (result.Data == 0)
                {
                    throw new Exception("数据新增异常,JSON:" + Newtonsoft.Json.JsonConvert.SerializeObject(model));
                }
            }, false);

            return(Json(resdata));
        }
        //[ValidateAntiForgeryToken]
        public ActionResult DocTypeUpdate([FromBody] DocumentType model)
        {
            var resdata = AutoException.Excute <bool>((result) =>
            {
                model.UpdateBy = "admin";
                model.UpdateDt = DateTime.Now;
                result.Data    = DocumentTypeDAL.Update(model);
                if (result.Data == false)
                {
                    throw new Exception("数据新增异常,JSON:" + Newtonsoft.Json.JsonConvert.SerializeObject(model));
                }
            }, false);

            return(Json(resdata));
        }
Beispiel #10
0
        public async Task <ActionResult> Update([FromBody] ArticleContent model)
        {
            var resdata = await AutoException.Excute <ArticleContent>(async (result) =>
            {
                model.UpdateBy = "admin";
                model.UpdateDt = DateTime.Now;
                var res        = await ArticleContentDAL.UpdateAsync(model);
                result.Data    = model;
                if (!res)
                {
                    throw new Exception("数据修改异常,JSON:" + Newtonsoft.Json.JsonConvert.SerializeObject(model));
                }
            }, false);

            return(Json(resdata));
        }
Beispiel #11
0
        public async Task <ActionResult> Delete(string id)
        {
            var resdata = await AutoException.Excute <long>(async (result) =>
            {
                string[] idstr = id.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                foreach (var item in idstr)
                {
                    var bl = await SysUserDAL.DeleteAsync(Convert.ToInt32(item));
                    if (!bl)
                    {
                        throw new Exception("数据删除异常,ID:" + item);
                    }
                }
            }, true);

            return(Json(resdata));
        }
Beispiel #12
0
        public async Task <ActionResult> Create([FromBody] SysDictionary model)
        {
            var resdata = await AutoException.Excute <long>(async (result) =>
            {
                model.CreateBy = "admin";
                model.CreateDt = DateTime.Now;
                model.Status   = 1;
                model.ParentID = model.ParentID == null ? 0 : model.ParentID;
                result.Data    = await SysDictionaryDAL.InsertAsync(model);
                if (result.Data == 0)
                {
                    throw new Exception("数据新增异常,JSON:" + Newtonsoft.Json.JsonConvert.SerializeObject(model));
                }
            }, false);

            return(Json(resdata));
        }
Beispiel #13
0
        public async Task <ActionResult> UpdatePwd(string id, string pwd)
        {
            var resdata = await AutoException.Excute <long>(async (result) =>
            {
                string[] idstr = id.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                foreach (var item in idstr)
                {
                    var model      = await SysUserDAL.GetByOneAsync(w => w.Id == Convert.ToInt32(item));
                    model.Password = pwd; //MD5编码
                    var bl         = await SysUserDAL.UpdateAsync(model);
                    if (!bl)
                    {
                        throw new Exception("密码修改异常,ID:" + item);
                    }
                }
            }, false);

            return(Json(resdata));
        }
Beispiel #14
0
        public async Task <ActionResult> Auth([FromBody] SysRoleView model)
        {
            var resdata = await AutoException.Excute <SysRole>(async (result) =>
            {
                //删除
                SysRoleMenuDAL.Delete(del => del.RoleId == model.Id);
                SysRoleButtonDAL.Delete(del => del.RoleId == model.Id);

                if (!string.IsNullOrEmpty(model.authids))
                {
                    string[] idstr = model.authids.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    List <SysRoleMenu> rolelist = (from p in idstr
                                                   select new SysRoleMenu
                    {
                        RoleId = model.Id,
                        MenuId = Convert.ToInt32(p),
                        Status = 1,
                        CreateDt = DateTime.Now,
                        CreateBy = model.UpdateBy
                    }).ToList();
                    await SysRoleMenuDAL.BatchInsertAsync(rolelist);

                    string[] btnids = model.btnids.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    List <SysRoleButton> btnlist = (from p in btnids
                                                    select new SysRoleButton
                    {
                        RoleId = model.Id,
                        ButtonId = Convert.ToInt32(p),
                        Status = 1,
                        CreateDt = DateTime.Now,
                        CreateBy = model.UpdateBy
                    }).ToList();
                    await SysRoleButtonDAL.BatchInsertAsync(btnlist);
                }
            }, false);

            return(Json(resdata));
        }