示例#1
0
        public bool ChangeDetails(User loggedInUser, List <string> columns, List <string> values)
        {
            string command = $"DB_UPDATE_DETAILS:{loggedInUser.UserId}/";

            for (int i = 0; i < columns.Count; i++)
            {
                if (i + 1 == columns.Count)
                {
                    command += columns[i] + "/";
                }
                else
                {
                    command += columns[i] + "%";
                }
            }
            for (int i = 0; i < values.Count; i++)
            {
                if (i + 1 == values.Count)
                {
                    command += values[i] + ";";
                }
                else
                {
                    command += values[i] + "%";
                }
            }
            SendMessage(command);

            if (ReceivedString.StartsWith("ACK"))
            {
                return(true);
            }
            return(false);
        }
示例#2
0
 public string Req_VerificationKey(User loggedInUser)
 {
     SendMessage($"DB_REQ_VERIFICATIONKEY:{loggedInUser.UserId};");
     if (ReceivedString.StartsWith("ACK"))
     {
         return(ReceivedData[0]);
     }
     return(null);
 }
示例#3
0
 public bool LockBike(string standId, User loggedInUser)
 {
     SendMessage($"DB_LOCK_BIKE:{standId}/{loggedInUser.UserId};");
     if (ReceivedString.StartsWith("ACK"))
     {
         return(true);
     }
     return(false);
 }
示例#4
0
 public string Req_Check_Exsisting_session(User loggedInUser)
 {
     SendMessage($"DB_REQ_EXISTING_SESSION_USER:{loggedInUser.UserId};");
     if (ReceivedString.StartsWith("ACK"))
     {
         DateTime dateTime = ParseLockMoment(ReceivedData[2]);
         return(dateTime.ToString("hh:mm:ss dd-MM-yyyy"));
     }
     return(null);
 }
示例#5
0
 public string[] Req_AllStandId()
 {
     SendMessage("DB_REQ_ALLSTANDID;");
     if (ReceivedString.StartsWith("ACK"))
     {
         string[] allStands = ValuesStringTrimmer(ReceivedData[0]);
         return(allStands);
     }
     return(null);
 }
示例#6
0
 public void ChangeBalance(User loggedinUser, decimal value)
 {
     SendMessage($"DB_CHANGE_BALANCE:{loggedinUser.UserId}/{value};");
     if (ReceivedString.StartsWith("ACK"))
     {
         decimal newbalance;
         if (decimal.TryParse(ReceivedData[1], out newbalance))
         {
             loggedinUser.RaiseBalance(newbalance);
         }
     }
 }
示例#7
0
 public decimal Req_Price(User loggedInUser)
 {
     SendMessage($"DB_REQ_PRICE:{loggedInUser.UserId};");
     if (ReceivedString.StartsWith("ACK"))
     {
         decimal price;
         if (decimal.TryParse(ReceivedData[1], out price))
         {
             return(price);
         }
     }
     return(0);
 }
示例#8
0
        public bool ReqLogin(string email_address, string password)
        {
            SendMessage($"DB_REQ_LOGIN:{email_address};");
            string rPassword = ReceivedData[2];

            if (ReceivedString.StartsWith("ACK"))
            {
                if (rPassword == password)
                {
                    return(true);
                }
            }
            return(false);
        }
示例#9
0
 public User ReqUser(string userId)
 {
     SendMessage($"DB_REQ_USER:{userId};");
     if (ReceivedString.StartsWith("ACK"))
     {
         string   first_name    = ReceivedData[1];
         string   last_name     = ReceivedData[2];
         DateTime date_of_birth = ParseBirthDate(ReceivedData[3]);
         string   email_address = ReceivedData[4];
         string   password      = ReceivedData[5];
         Address  address       = ParseAddress(ReceivedData[6]);
         decimal  balance       = Convert.ToDecimal(ReceivedData[7]);
         return(new User(userId, first_name, last_name, date_of_birth, email_address, password, address, balance));
     }
     return(null);
 }
示例#10
0
 public bool Registrate(string first_name, string last_name, DateTime date_of_birth, string email, string password, Address address)
 {
     if (first_name != null && last_name != null && date_of_birth != null && password != null && address != null)
     {
         if (CheckConnection())
         {
             SendMessage($"DB_INSERT_REGISTRATE:{first_name}/{last_name}/{date_of_birth.Day}_{date_of_birth.Month}_{date_of_birth.Year}/{email}/{password}/{address};");
             if (ReceivedString.StartsWith("ACK"))
             {
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
     }
     return(false);
 }