/// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (TicketId != null)
         {
             hashCode = hashCode * 59 + TicketId.GetHashCode();
         }
         if (OperationDate != null)
         {
             hashCode = hashCode * 59 + OperationDate.GetHashCode();
         }
         if (TicketTypeId != null)
         {
             hashCode = hashCode * 59 + TicketTypeId.GetHashCode();
         }
         if (OperationTypeId != null)
         {
             hashCode = hashCode * 59 + OperationTypeId.GetHashCode();
         }
         if (StatusId != null)
         {
             hashCode = hashCode * 59 + StatusId.GetHashCode();
         }
         return(hashCode);
     }
 }
Esempio n. 2
0
        private static async Task UpdateResults(TicketTypeId id)
        {
            var url = ConfigurationManager.AppSettings["ResultsApi"];

            if (!string.IsNullOrEmpty(url))
            {
                var json = await GetJsonResponse(id, url);

                var model = JsonConvert.DeserializeObject <ResultsModel>(json);

                if (model.Error == 0)
                {
                    DataAccess.UpdateWinningNumbers(id, model);
                }
            }
        }
Esempio n. 3
0
        private static async Task <string> GetJsonResponse(TicketTypeId id, string url)
        {
            if (id == TicketTypeId.Powerball)
            {
                url += ConfigurationManager.AppSettings["Powerball"];
            }
            else if (id == TicketTypeId.MegaMillion)
            {
                url += ConfigurationManager.AppSettings["MegaMillions"];
            }

            var client   = new HttpClient();
            var response = await client.GetAsync(url);

            return(await response.Content.ReadAsStringAsync());
        }
Esempio n. 4
0
        public static void UpdateJackpot(TicketTypeId id, JackpotModel model)
        {
            using (SqlConnection connection = new SqlConnection(connString))
                using (connection)
                {
                    connection.Open();

                    var Command = new SqlCommand("UpdateJackpot", connection)
                    {
                        CommandType = CommandType.StoredProcedure
                    };

                    Command.Parameters.AddWithValue("@TicketTypeId", id);
                    Command.Parameters.AddWithValue("@Jackpot", model.Jackpot);

                    Command.ExecuteNonQuery();
                }
        }
Esempio n. 5
0
        public static void UpdateWinningNumbers(TicketTypeId id, ResultsModel model)
        {
            using (SqlConnection connection = new SqlConnection(connString))
                using (connection)
                {
                    connection.Open();

                    var command = new SqlCommand("UpdateWinningNumbers", connection)
                    {
                        CommandType = CommandType.StoredProcedure
                    };

                    command.Parameters.AddWithValue("@TicketTypeId", id);
                    command.Parameters.AddWithValue("@DrawDate", model.Draw);
                    command.Parameters.AddWithValue("@WinningNumbers", model.WinningNumbers);

                    command.ExecuteNonQuery();
                }
        }
        /// <summary>
        /// Returns true if TicketFilterResult instances are equal
        /// </summary>
        /// <param name="other">Instance of TicketFilterResult to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(TicketFilterResult other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     TicketId == other.TicketId ||
                     TicketId != null &&
                     TicketId.Equals(other.TicketId)
                     ) &&
                 (
                     OperationDate == other.OperationDate ||
                     OperationDate != null &&
                     OperationDate.Equals(other.OperationDate)
                 ) &&
                 (
                     TicketTypeId == other.TicketTypeId ||
                     TicketTypeId != null &&
                     TicketTypeId.Equals(other.TicketTypeId)
                 ) &&
                 (
                     OperationTypeId == other.OperationTypeId ||
                     OperationTypeId != null &&
                     OperationTypeId.Equals(other.OperationTypeId)
                 ) &&
                 (
                     StatusId == other.StatusId ||
                     StatusId != null &&
                     StatusId.Equals(other.StatusId)
                 ));
        }