public List<Int64> UserLogin(string username, string password, short counterNumber) { try { using (Cafeteria_Vernier_dbEntities cvDatabase= new Cafeteria_Vernier_dbEntities()) { var loginfo = cvDatabase.CustomerAccounts.FirstOrDefault(x=>x.UserID.Equals(username) && x.Password.Equals(password) && x.Minutes>1 && x.Status==false); if (loginfo!=null) { UserLoginHistory newLoginHistory= new UserLoginHistory { AutoInc= default(long), CounterNumber=counterNumber, StratTime=DateTime.Now, UserID=username, }; cvDatabase.AddToUserLoginHistories(newLoginHistory); loginfo.Status=true; loginfo.Counternumber=counterNumber; cvDatabase.SaveChanges(); List<Int64> customerinfo = new List<Int64>(); customerinfo.Add(loginfo.Minutes); customerinfo.Add(newLoginHistory.AutoInc); return customerinfo; } else { throw new FaultException(ServiceVariables.ERROR_MESSAGES[0, 0]); } } } catch (Exception error) { throw new FaultException(error.Message); } }
/// <summary> /// Deprecated Method for adding a new object to the UserLoginHistories EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToUserLoginHistories(UserLoginHistory userLoginHistory) { base.AddObject("UserLoginHistories", userLoginHistory); }
public List<Int64> TeamLogin(string username, string password, short counterNumber, string teamName) { try { using (Cafeteria_Vernier_dbEntities cvDatabase= new Cafeteria_Vernier_dbEntities()) { var teamInfo = cvDatabase.TeamAccounts.FirstOrDefault(x => x.Team.Name.Equals(teamName) && x.Status == false); var memberInfo = cvDatabase.TeamMembers.FirstOrDefault(x => x.UserID.Equals(username)); var userInfo = cvDatabase.CustomerAccounts.FirstOrDefault(x => x.UserID.Equals(username) && x.Password.Equals(password)); var isTeamAdmin = cvDatabase.Teams.FirstOrDefault(x => x.Name.Equals(teamName) && x.AdminName.Equals(username)); if (teamInfo!=null && (memberInfo!=null || isTeamAdmin!=null ) && userInfo!=null) { UserLoginHistory newUserLoginHistory = new UserLoginHistory { AutoInc =default(long), CounterNumber=counterNumber, StratTime=DateTime.Now, TeamName=teamName, UserID=username }; cvDatabase.AddToUserLoginHistories(newUserLoginHistory); teamInfo.Status = true; var userinfo= cvDatabase.CustomerAccounts.FirstOrDefault(x => x.UserID.Equals(username)); userinfo.Status = false; userinfo.Counternumber = counterNumber; cvDatabase.SaveChanges(); List<Int64> teamLoginInfo = new List<Int64>(); teamLoginInfo.Add(teamInfo.Minutes); teamLoginInfo.Add(newUserLoginHistory.AutoInc); return teamLoginInfo; } else { throw new FaultException(ServiceVariables.ERROR_MESSAGES[0, 1]); } } } catch (Exception error) { throw new FaultException(error.Message); } }
/// <summary> /// Create a new UserLoginHistory object. /// </summary> /// <param name="autoInc">Initial value of the AutoInc property.</param> /// <param name="userID">Initial value of the UserID property.</param> /// <param name="stratTime">Initial value of the StratTime property.</param> /// <param name="counterNumber">Initial value of the CounterNumber property.</param> public static UserLoginHistory CreateUserLoginHistory(global::System.Int64 autoInc, global::System.String userID, global::System.DateTime stratTime, global::System.Int16 counterNumber) { UserLoginHistory userLoginHistory = new UserLoginHistory(); userLoginHistory.AutoInc = autoInc; userLoginHistory.UserID = userID; userLoginHistory.StratTime = stratTime; userLoginHistory.CounterNumber = counterNumber; return userLoginHistory; }