示例#1
0
文件: UserBL.cs 项目: xdj/NFCShopping
        /*用户签到函数*/
        public bool AutoAddVisitedTime(User origuser)
        {
            if (!origuser.lastVisitedDate.Date.Equals(DateTime.Now.Date))
            {
                try
                {
                    User user = new User();
                    user.userID = origuser.userID;
                    user.userPassword = origuser.userPassword;
                    user.userName = origuser.userName;
                    user.visitedTimes = origuser.visitedTimes + 1;
                    user.gender = origuser.gender;
                    //user.lastVisitedDate = origuser.lastVisitedDate;
                    //注意这里要改时间啊。。。。
                    user.lastVisitedDate = DateTime.Now;

                    mRepository.UpdateUser(user, origuser, true);
                    return true;
                }
                catch (Exception ex)
                {
                    return false;
                }
            }
            return false ;
        }
示例#2
0
 /*删除用户*/
 public void DeleteUser(User user)
 {
     try
     {
         mRepository.DeleteUser(user, true);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#3
0
        public void InsertUser(User user, bool isImmediateSave)
        {
            try
            {
                mContext.Users.AddObject(user);

                if (isImmediateSave)
                {
                    mContext.SaveChanges();
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }
示例#4
0
        public void UpdateUser(User user, User origUser, bool isImmediateSave)
        {
            try
            {
                mContext.Users.Attach(origUser);
                mContext.Users.ApplyCurrentValues(user);

                if (isImmediateSave)
                {
                    mContext.SaveChanges();
                }
            }
            catch(Exception e)
            {
                throw e;
            }
        }
示例#5
0
        public void DeleteUser(User user, bool isImmediateSave)
        {
            try
            {
                mContext.Users.Attach(user);
                mContext.Users.DeleteObject(user);

                if (isImmediateSave)
                {
                    mContext.SaveChanges();
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }
 public User Regist(String userName,String password,int gender)
 {
     UserBL bl = new UserBL();
     User user = new User();
     user.userName = userName;
     user.userPassword = password;
     user.gender = gender;
     try
     {
         return bl.Regist(user);
     }
     catch
     {
         return null;
     }
 }
 public User Login(String userName, String password)
 {
     UserBL bl = new UserBL();
     User user = new User();
     user.userName = userName;
     user.userPassword = password;
     return bl.Login(user);
 }
示例#8
0
 /// <summary>
 /// 用于向 Users EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet&lt;T&gt; 属性的 .Add 方法。
 /// </summary>
 public void AddToUsers(User user)
 {
     base.AddObject("Users", user);
 }
示例#9
0
 /// <summary>
 /// 创建新的 User 对象。
 /// </summary>
 /// <param name="userID">userID 属性的初始值。</param>
 /// <param name="userName">userName 属性的初始值。</param>
 /// <param name="userPassword">userPassword 属性的初始值。</param>
 /// <param name="visitedTimes">visitedTimes 属性的初始值。</param>
 /// <param name="lastVisitedDate">lastVisitedDate 属性的初始值。</param>
 public static User CreateUser(global::System.Int32 userID, global::System.String userName, global::System.String userPassword, global::System.Int32 visitedTimes, global::System.DateTime lastVisitedDate)
 {
     User user = new User();
     user.userID = userID;
     user.userName = userName;
     user.userPassword = userPassword;
     user.visitedTimes = visitedTimes;
     user.lastVisitedDate = lastVisitedDate;
     return user;
 }
示例#10
0
 /*用户注册业务逻辑*/
 public User Regist(User user)
 {
     user.lastVisitedDate = DateTime.Now;
     user.visitedTimes = 0;
     try
     {
         mRepository.InsertUser(user, true);
         return FindUserByUsername(user.userName);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#11
0
 /*用户登录的业务逻辑*/
 public User Login(User user)
 {
     User temp = FindUserByUsername(user.userName);
     if (!temp.Equals(null))
     {
         if (temp.userPassword.Equals(user.userPassword))
         {
             return temp;
         }
     }
     return null;
 }