Example #1
0
        public JsonResult AddUser(Info_User model)
        {
            Result        result      = new Result();
            JsonResult    jsonResult  = new JsonResult();
            Info_User_BLL infoUserBll = new Info_User_BLL();
            bool          isOkAdd;

            model.IsDelete = false;
            if (model.ID == 0)
            {
                isOkAdd = infoUserBll.Insert(model);
                if (isOkAdd)
                {
                    result.message = "添加成功";
                }
            }
            else
            {
                isOkAdd = infoUserBll.Update(model);
                if (isOkAdd)
                {
                    result.message = "更新成功";
                }
            }

            jsonResult.Data = result;
            return(jsonResult);
        }
Example #2
0
        public JsonResult GetUserInfo(int userId)
        {
            Result        result      = new Result();
            JsonResult    jsonResult  = new JsonResult();
            Info_User_BLL infoUserBll = new Info_User_BLL();
            Info_User     infoUser    = infoUserBll.GetModelByID(userId);

            if (infoUser != null)
            {
                result.data = infoUser;
            }

            jsonResult.Data = result;
            return(jsonResult);
        }
Example #3
0
File: InfoBLL.cs Project: 17/YunPos
        public override BaseResult Get(Hashtable param)
        {
            BaseResult br   = new BaseResult();
            Info       info = new Info();

            if (param.ContainsKey("bm"))
            {
                Hashtable hb = new Hashtable();
                hb["bm"] = param["bm"];
                Info_Type infoType = new Info_Type();
                infoType = DAL.GetItem <Info_Type>(typeof(Info_Type), hb);
                param["id_info_type"] = infoType.id;
                info = (Info)DAL.GetItem(typeof(Info), param) ?? new Info();
            }
            else
            {
                info = (Info)DAL.GetItem(typeof(Info), param) ?? new Info();
            }
            br.Data = info;
            //当查询我的公告详情时,直接return结果
            if (param.ContainsKey("NoticeFlag"))
            {
                br.Success = true;
                return(br);
            }
            //获取info_User对象
            param.Add("id_info", param["id"].ToString());
            Info_User user = (Info_User)DAL.GetItem(typeof(Info_User), param) ?? new Info_User();

            if (user.flag_reade == 0)
            {
                //修改阅读标示
                param.Add("new_rq", DateTime.Now);
                param.Add("new_flag_reade", 1);
                int flag = DAL.UpdatePart(typeof(Info_User), param);
                if (flag == -1)
                {
                    //info公告阅读数量加1
                    int readNum = (int)info.sl_read + 1;
                    param.Remove("id_user");
                    param.Add("new_sl_read", readNum);
                    DAL.UpdatePart(typeof(Info), param);
                }
            }

            br.Success = true;
            return(br);
        }
Example #4
0
        public ActionResult Item(string type = "", string id = "")
        {
            string     ParentTitle = "";
            Hashtable  param       = new Hashtable();
            BaseResult br          = new BaseResult();
            long       id_user     = GetLoginInfo <long>("id_user");

            param.Add("id_user", id_user);
            param.Add("id_info", id);
            param.Add("flag_reade", 1);
            br = BusinessFactory.InfoUser.GetCount(param);
            var count = (int)br.Data;

            if (count <= 0)
            {
                Info_User info = new Info_User();
                info.id_user    = id_user;
                info.id_info    = Convert.ToInt64(id);
                info.flag_reade = 1;
                info.flag_from  = "pc";
                info.rq         = DateTime.Now;
                BusinessFactory.InfoUser.Add(info);
            }
            param.Clear();
            param.Add("id", id);

            if (type == "yw")
            {
                ParentTitle = "业务消息";
                param.Add("bm", "business");
            }
            if (type == "xt")
            {
                ParentTitle = "系统公告";
                param.Add("bm", "system");
            }
            if (type == "sj")
            {
                ParentTitle = "升级公告";
                param.Add("bm", "update");
            }
            br = BusinessFactory.Info.Get(param);
            ViewBag.ParentTitle = ParentTitle;
            ViewBag.type        = type;
            return(View(br.Data));
        }
Example #5
0
        public JsonResult GetLoginByPhone(Info_User_Model model)
        {
            JsonResult    jr          = new JsonResult();
            Result        result      = new Result();
            Info_User_BLL infoUserBll = new Info_User_BLL();
            Info_User     infoUser    = infoUserBll.Login(model.Phone, model.PassWord);

            if (infoUser != null)
            {
                result.message = "登录成功";
                result.type    = "success";
                result.data    = new { reutrnUrl = Url.Content("~/User/Index") };
            }
            else
            {
                result.message = "登录失败,请检查用户名和密码";
                result.type    = "error";
            }

            jr.Data = result;
            return(jr);
        }
Example #6
0
        public async static Task InitData(ApplicationDbContext context)
        {
            if (context.Database != null && context.Database.EnsureCreated())
            {
                //角色
                var role = new Info_Role[] {
                    new Info_Role {
                        Name = "超级管理员"
                    },
                    new Info_Role {
                        Name = "普通用户"
                    }
                };
                context.Roles.AddRange(role);
                //用户
                var user = new Info_User[]
                {
                    new Info_User {
                        LoginId = "admin", Email = "*****@*****.**", Pwd = "000000", Status = 1
                    },
                    new Info_User {
                        LoginId = "lnice", Mobile = "123456789", Email = "*****@*****.**", Pwd = "000000", Status = 1
                    }
                };
                context.Users.AddRange(user);
                //菜单
                var menu = new Info_Menu[]
                {
                    new Info_Menu {
                        Fid = 0, Name = "首页", Href = "#", Sort = 0
                    },
                    new Info_Menu {
                        Fid = 0, Name = "教师业绩管理", Href = "#", Sort = 1
                    },
                    new Info_Menu {
                        Fid = 0, Name = "教师评价管理", Href = "#", Sort = 2
                    },
                    new Info_Menu {
                        Fid = 0, Name = "系统设置", Href = "#", Sort = 3
                    }
                };
                context.Menus.AddRange(menu);
                context.SaveChanges();
                //角色用户关系绑定
                var userrole = new Info_UserRole[]
                {
                    new Info_UserRole {
                        RoleId = role[0].Id, UserId = user[0].Id
                    },
                    new Info_UserRole {
                        RoleId = role[1].Id, UserId = user[1].Id
                    }
                };
                context.UserRoles.AddRange(userrole);
                //2级菜单
                var menu1 = new Info_Menu[]
                {
                    new Info_Menu {
                        Fid = menu[1].Id, Name = "业绩管理", Href = "#", Sort = 0
                    },
                    new Info_Menu {
                        Fid = menu[1].Id, Name = "我的业绩", Href = "#", Sort = 1
                    },
                    new Info_Menu {
                        Fid = menu[1].Id, Name = "业绩统计", Href = "#", Sort = 2
                    }
                };
                context.Menus.AddRange(menu1);

                await context.SaveChangesAsync();
            }
        }
Example #7
0
 public override void Add(Info_User info)
 {
     DAL.Add(info);
 }