public List <LotteryDraw> ToDraws() { string[] rows = new string[3]; LotteryDraw losowanie; while (!reader.EndOfStream) { List <int> liczby = new List <int>(); rows = reader.ReadLine().Split(' '); var liczbyTemp = rows[2].Split(','); foreach (var item in liczbyTemp) { liczby.Add(int.Parse(item)); } string[] daty = rows[1].Split('.'); string poprawnaData = daty[2] + "-" + daty[1] + "-" + daty[0]; losowanie = new LotteryDraw { Index = int.Parse(rows[0].Trim('.')), DrawnNumbers = liczby, Date = DateTime.Parse(poprawnaData) }; losowania.Add(losowanie); } file.Close(); reader.Close(); return(losowania); }
public async Task <HttpResponseMessage> Update(LotteryDraw draw) { var commandResult = await LotteryService.UpdateDraw(draw); if (commandResult == CommandResult.NotFound) { return(Request.CreateResponse(HttpStatusCode.NotFound)); } return(Request.CreateResponse(commandResult == CommandResult.Invalid ? HttpStatusCode.BadRequest : HttpStatusCode.OK)); }
public void Update(LotteryDraw lotteryDraw) { var draw = FindByName(lotteryDraw.Name); if (draw == null) { throw new ArgumentException("Lottery Draw could not be found"); } draw = lotteryDraw; }
public async Task <CommandResult> CreateDraw(LotteryDraw lotteryDraw) { var result = await _lotteryDrawRepository.Find(lotteryDraw.Name); if (result != null) { return(CommandResult.AlreadyExists); } await _lotteryDrawRepository.Create(lotteryDraw); return(CommandResult.Ok); }
public async Task <CommandResult> UpdateDraw(LotteryDraw lotteryDraw) { var result = await _lotteryDrawRepository.Find(lotteryDraw.Name); if (result == null) { return(CommandResult.NotFound); } if ( lotteryDraw.WinningPrimaryNumbers.Any( x => x < result.RangePrimaryNumbers.Item1 || x > result.RangePrimaryNumbers.Item2) || lotteryDraw.WinningSecondaryNumbers.Any( x => x < result.RangeSecondaryNumbers.Item1 || x > result.RangeSecondaryNumbers.Item2)) { return(CommandResult.Invalid); } await _lotteryDrawRepository.Update(lotteryDraw); return(CommandResult.Ok); }
public void Create(LotteryDraw lotteryDraw) { _inMemoryDb.Add(lotteryDraw); }
public async Task <HttpResponseMessage> Create(LotteryDraw draw) { var commandResult = await LotteryService.CreateDraw(draw); return(Request.CreateResponse(commandResult == CommandResult.AlreadyExists ? HttpStatusCode.BadRequest : HttpStatusCode.Created)); }
public HomeViewModel() { //MyItemsSource = new ObservableCollection<TestGame>() //{ // new TestGame(){ game_type = "Powerball", multiplier_type = "PowerPlay"}, // new TestGame(){ game_type = "Megamillions", multiplier_type = "Megaplier"} //}; //MyCommand = new Command(() => //{ // Debug.WriteLine("Position seleclted."); //}); client = new HttpClient(); client.BaseAddress = new Uri("https://lotterygeniusapi.azurewebsites.net/"); client.DefaultRequestHeaders.Add("Access-Control-Allow-Origin", "[GET]"); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); build_current_powerball(); build_next_powerball(); build_current_megamillions(); build_next_megamillions(); var p = new LotteryDraw() { type = "powerball", ball1 = powerball.powerball1, ball2 = powerball.powerball2, ball3 = powerball.powerball3, ball4 = powerball.powerball4, ball5 = powerball.powerball5, bonus_ball = powerball.powerball, multiplier = powerball.powerplay, draw_date = powerball.powerballDrawDate, jackpot = powerball.powerballJackpot, next_draw_date = next_powerball.next_jackpot_date, next_jackpot = next_powerball.next_jackpot, game_image = "powerball_pp.png", bonus_image = "powerBall.png", bonus_text_color = "White" }; var m = new LotteryDraw() { type = "megamillions", ball1 = megamillion.megamillion1, ball2 = megamillion.megamillion2, ball3 = megamillion.megamillion3, ball4 = megamillion.megamillion4, ball5 = megamillion.megamillion5, bonus_ball = megamillion.megaball, multiplier = megamillion.megaplier, draw_date = megamillion.megamillionDrawDate, jackpot = megamillion.megamillionJackpot, next_draw_date = next_megamillion.next_jackpot_date, next_jackpot = next_megamillion.next_jackpot, game_image = "MegaMillions_Logo.png", bonus_image = "megaBall.png", bonus_text_color = "Black" }; MyItemsSource = new ObservableCollection <LotteryDraw>(); MyItemsSource.Add(p); MyItemsSource.Add(m); }