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); } }
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); } }