Exemplo n.º 1
0
        public void UpdateGymDetails(GymGetInfoOutProto gym)
        {
            using (var context = new RocketMapContext())
            {
                if (gym.GymStatusAndDefenders == null || gym.GymStatusAndDefenders.PokemonFortProto == null)
                {
                    return;
                }

                List <String> parameters = new List <String>();
                if (gym.Name != null && gym.Name.Length > 0)
                {
                    parameters.Add($"name=\'{MySQLEscape(gym.Name)}\'");
                }
                if (gym.Name != null && gym.Name.Length > 0)
                {
                    parameters.Add($"description=\'{MySQLEscape(gym.Description)}\'");
                }
                if (gym.Name != null && gym.Name.Length > 0)
                {
                    parameters.Add($"url=\"{MySQLEscape(gym.Url)}\"");
                }

                String updateQUery = $"UPDATE gymdetails SET {String.Join(",", parameters.ToArray())} WHERE gym_id = \"{gym.GymStatusAndDefenders.PokemonFortProto.FortId}\"";

                try
                {
                    context.Database.ExecuteSqlRaw(updateQUery);
                }
                catch (Exception e)
                {
                    Log.Information(e.Message);
                    Log.Information(e.StackTrace);
                    Log.Information($"Object: {JsonSerializer.Serialize(gym)} \n\n Gym Query: {updateQUery}");
                }
            }
        }
Exemplo n.º 2
0
 public void AddDetails(GymGetInfoOutProto gymDetails)
 {
     // Check if gym details name is null or empty
     if (!string.IsNullOrEmpty(gymDetails.Name))
     {
         // Check if current gym name and gym details gym name are different
         if (string.Compare(Name, gymDetails.Name, true) != 0)
         {
             // If so assign new name
             Name = gymDetails.Name;
         }
     }
     // Check if gym details url is null or empty
     if (!string.IsNullOrEmpty(gymDetails.Url))
     {
         // Check if current gym url and gym details gym url are different
         if (string.Compare(Url, gymDetails.Url, true) != 0)
         {
             // If so assign new url
             Url = gymDetails.Url;
         }
     }
     Updated = DateTime.UtcNow.ToTotalSeconds();
 }