Example #1
0
        /// <summary>
        /// 创建管理员
        /// </summary>
        /// <param name="admin"></param>
        /// <returns></returns>
        public AdminUser CreateAdmin(AdminUser admin)
        {
            Check.Argument.IsNotNull(admin, "admin");

            DbProvider.Add(admin);
            DbProvider.SaveChanges();

            return admin;
        }
Example #2
0
        /// <summary>
        /// 验证管理员
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="password"></param>
        /// <param name="admin"></param>
        /// <returns></returns>
        public virtual bool Validate(string userName, string password, out AdminUser admin)
        {
            var validate = false;
            admin = null;

            admin = DbProvider.D<AdminUser>().FirstOrDefault(x => x.UserName == userName);

            if (admin != null)
            {
                if (admin.Password == password)
                {
                    validate = true;
                }
            }
            if (validate)
            {
                admin.LoginTime = DateTime.Now;
                DbProvider.SaveChanges();
            }
            return validate;
        }
Example #3
0
        public ActionResult PostEdit(AdminUser model)
        {
            using (LoveBankDBContext db = new LoveBankDBContext())
            {

                AdminUser user = db.T_AdminUser.First(x => x.ID == model.ID);
                if (user == null) return Error("用户不存在");

                user.DeptId = model.DeptId;
                user.RealName = model.RealName;
                user.RoleID = model.RoleID;
                db.Update<AdminUser>(user);
                db.SaveChanges();

                return Success("修改成功");
            }
        }
Example #4
0
 public void AddAdminLog(AdminUser admin, string logInfo, string bussiness, string ip)
 {
     var log = new AdminLog(logInfo, admin==null? 0 : admin.ID, bussiness, ip);
     DbProvider.Add(log);
     DbProvider.SaveChanges();
 }
Example #5
0
        public ActionResult PostAdd(AdminUser model)
        {
            model.LoginTime = DateTime.Now;
            model.LoginIP =Utility.GetIP();
            using (LoveBankDBContext db = new LoveBankDBContext())
            {
                if (db.T_AdminUser.Count(u => u.UserName.Trim() == model.UserName.Trim()) > 0)
                {
                    db.Dispose();
                    return Error("用户已经存在");
                }

                db.T_AdminUser.Add(model);
                db.SaveChanges();
                return Success("操作成功");
            }
        }