Exemplo n.º 1
0
 public bool TeamLogout(string username, string teamName, Int64 loginHistoryID)
 {
     try
     {
         using (Cafeteria_Vernier_dbEntities cvDatabase = new Cafeteria_Vernier_dbEntities())
         {
             var userInfo = cvDatabase.CustomerAccounts.FirstOrDefault(x => x.UserID.Equals(username));
             var teamInfo = cvDatabase.TeamAccounts.FirstOrDefault(x => x.Name.Equals(teamName));
             if (userInfo != null && teamInfo != null)
             {
                 userInfo.Status        = false;
                 userInfo.Counternumber = 0;
                 teamInfo.Status        = false;
                 cvDatabase.UserLoginHistories.First(x => x.AutoInc == loginHistoryID).EndTime = DateTime.Now;
                 cvDatabase.SaveChanges();
                 return(true);
             }
             else
             {
                 throw new FaultException(ServiceVariables.ERROR_MESSAGES[0, 3]);
             }
         }
     }
     catch (Exception)
     {
         throw new FaultException(ServiceVariables.ERROR_MESSAGES[0, 2]);
     }
 }
Exemplo n.º 2
0
 public bool UpdateTeam(string teamName, List <AllUserAndTeam> teamMembers)
 {
     try
     {
         using (Cafeteria_Vernier_dbEntities cvDatabase = new Cafeteria_Vernier_dbEntities())
         {
             foreach (var existingMember in cvDatabase.TeamMembers.Where(x => x.Name.Equals(teamName)))
             {
                 cvDatabase.TeamMembers.DeleteObject(existingMember);
             }
             foreach (AllUserAndTeam teamMember in teamMembers)
             {
                 cvDatabase.AddToTeamMembers(new TeamMember {
                     Name = teamName, UserID = teamMember.Name
                 });
             }
             cvDatabase.SaveChanges();
             return(true);
         }
     }
     catch (Exception error)
     {
         throw new FaultException(error.Message);
     }
 }
Exemplo n.º 3
0
 public bool TeamMunitieCounter(string teamName, string username, short counterNumber)
 {
     try
     {
         lock (signalEntry)
         {
             using (Cafeteria_Vernier_dbEntities cvDatabase = new Cafeteria_Vernier_dbEntities())
             {
                 var teamAccount = cvDatabase.TeamAccounts.FirstOrDefault(x => x.Name.Equals(teamName) && x.Minutes > 1);
                 var userAccount = cvDatabase.CustomerAccounts.FirstOrDefault(x => x.UserID.Equals(username));
                 if (teamAccount != null && userAccount != null)
                 {
                     teamAccount.Minutes--;
                     teamAccount.Status        = true;
                     userAccount.Status        = true;
                     userAccount.Counternumber = counterNumber;
                     cvDatabase.SaveChanges();
                     return(true);
                 }
                 else
                 {
                     return(false);
                 }
             }
         }
     }
     catch
     {
         throw new FaultException(ServiceVariables.ERROR_MESSAGES[0, 4]);
     }
 }
Exemplo n.º 4
0
 public bool UserMunitieCounter(string username, short counterNumber)
 {
     try
     {
         using (Cafeteria_Vernier_dbEntities cvDatabase = new Cafeteria_Vernier_dbEntities())
         {
             var userAccount = cvDatabase.CustomerAccounts.FirstOrDefault(x => x.UserID.Equals(username) && x.Minutes > 1);
             if (userAccount != null)
             {
                 userAccount.Minutes--;
                 userAccount.Status        = true;
                 userAccount.Counternumber = counterNumber;
                 cvDatabase.SaveChanges();
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
     }
     catch (Exception error)
     {
         throw new FaultException(error.Message);
     }
 }
Exemplo n.º 5
0
 public bool DeleteMember(string teamName, AllUserAndTeam member)
 {
     try
     {
         using (Cafeteria_Vernier_dbEntities cvDatabase = new Cafeteria_Vernier_dbEntities())
         {
             cvDatabase.TeamMembers.DeleteObject(cvDatabase.TeamMembers.First(x => x.UserID.Equals(member.Name) && x.Name.Equals(teamName)));
             cvDatabase.SaveChanges();
             return(true);
         }
     }
     catch
     {
         throw new FaultException(ServiceVariables.ERROR_MESSAGES[0, 2]);
     }
 }
Exemplo n.º 6
0
 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);
     }
 }
Exemplo n.º 7
0
 public bool AccountUpdate(string username, Userinformation updateinfo)
 {
     try
     {
         using (Cafeteria_Vernier_dbEntities cvDatabase = new Cafeteria_Vernier_dbEntities())
         {
             var customerInfo = cvDatabase.CustomerInformations.First(x => x.UserID.Equals(username));
             customerInfo.Address    = updateinfo.Address;
             customerInfo.Email      = updateinfo.Email;
             customerInfo.Logo       = updateinfo.UserImage;
             customerInfo.NationalID = updateinfo.NationalID;
             customerInfo.Phone      = updateinfo.Phone;
             cvDatabase.SaveChanges();
             return(true);
         }
     }
     catch
     {
         throw new FaultException(ServiceVariables.ERROR_MESSAGES[0, 2]);
     }
 }
Exemplo n.º 8
0
 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>
 /// Check Cash Date
 /// </summary>
 public void CheckCashDate()
 {
     try
     {
         using (Cafeteria_Vernier_dbEntities cvDatabase = new Cafeteria_Vernier_dbEntities())
         {
             if (cvDatabase.Cashes.FirstOrDefault(x => x.EntryDate == DateTime.Today) == null)
             {
                 cvDatabase.AddToCashes(new Cash
                 {
                     EntryDate = DateTime.Today,
                     Amount    = 0
                 });
                 cvDatabase.SaveChanges();
             }
         }
     }
     catch (Exception ErrorException)
     {
         LogFileWriter.ErrorToLog("Loading Bill Configuration File", ErrorException);
     }
 }
Exemplo n.º 10
0
 public bool AddNewTeam(TeamInfo teamInfo, List <AllUserAndTeam> members)
 {
     try
     {
         using (Cafeteria_Vernier_dbEntities cvDatabase = new Cafeteria_Vernier_dbEntities())
         {
             cvDatabase.AddToTeams(new Team
             {
                 AdminName   = teamInfo.TeamAdmin,
                 JoinDate    = teamInfo.EntryDate,
                 Logo        = teamInfo.TeamImage,
                 Name        = teamInfo.TeamD,
                 TeamAccount = new TeamAccount
                 {
                     Minutes   = 0,
                     Name      = teamInfo.TeamD,
                     Status    = false,
                     EntryDate = DateTime.Today
                 }
             });
             foreach (AllUserAndTeam teamMember in members)
             {
                 cvDatabase.AddToTeamMembers(new TeamMember
                 {
                     AutoInc = default(long),
                     UserID  = teamMember.Name,
                     Name    = teamInfo.TeamD
                 });
             }
             cvDatabase.SaveChanges();
         }
         return(true);
     }
     catch (Exception)
     {
         throw new FaultException(ServiceVariables.ERROR_MESSAGES[0, 2]);
     }
 }
Exemplo n.º 11
0
 public bool PasswordChange(string username, string newPassword)
 {
     try
     {
         using (Cafeteria_Vernier_dbEntities cvDatabase = new Cafeteria_Vernier_dbEntities())
         {
             var customerInfo = cvDatabase.CustomerAccounts.FirstOrDefault(x => x.UserID.Equals(username));
             if (customerInfo != null)
             {
                 customerInfo.Password = newPassword;
                 cvDatabase.SaveChanges();
                 return(true);
             }
             else
             {
                 throw new FaultException(ServiceVariables.ERROR_MESSAGES[0, 2]);
             }
         }
     }
     catch (Exception)
     {
         throw new FaultException(ServiceVariables.ERROR_MESSAGES[0, 2]);
     }
 }