Esempio n. 1
0
 public bool Equals(SpotKey other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(other.location == location && other.spot == spot);
 }
Esempio n. 2
0
        async public Task <List <Item> > UpdateSpots(string tableName)
        {
            var request = new ScanRequest
            {
                TableName = tableName
            };

            var response = await _client.ScanAsync(request);

            List <Item> added = new List <Item>();

            foreach (Dictionary <string, AttributeValue> tableItem in response.Items)
            {
                string location   = "null";
                bool   occupied   = false;
                string spot       = "null";
                string timeIn     = "null";
                string billedTime = "null";

                foreach (KeyValuePair <string, AttributeValue> property in tableItem)
                {
                    if (property.Key == "Location")
                    {
                        location = property.Value.S;
                    }
                    else if (property.Key == "Occupied")
                    {
                        occupied = property.Value.BOOL;
                    }
                    else if (property.Key == "Spot")
                    {
                        spot = property.Value.N;
                    }
                    else if (property.Key == "TimeIn")
                    {
                        timeIn = property.Value.S;
                    }
                    else if (property.Key == "BilledTime")
                    {
                        billedTime = property.Value.S;
                    }
                }

                SpotKey key = new SpotKey()
                {
                    location = location,
                    spot     = spot
                };

                if (SpotLookup.ContainsKey(key))
                {
                    SpotLookup[key].Occupied   = occupied;
                    SpotLookup[key].TimeIn     = timeIn != "null" ? timeIn      : SpotLookup[key].TimeIn;
                    SpotLookup[key].BilledTime = billedTime != "null" ? billedTime  : SpotLookup[key].BilledTime;
                }
                else
                {
                    Item item = new Item()
                    {
                        Location   = location,
                        Occupied   = occupied,
                        Spot       = spot,
                        TimeIn     = timeIn,
                        BilledTime = billedTime,
                    };
                    added.Add(item);
                    SpotLookup.Add(key, item);
                }
            }

            return(added);
        }