public Task <bool> Handle(UpdateTypeLotteryCommand message, CancellationToken cancellationToken) { if (!message.IsValid()) { NotifyValidationErrors(message); return(Task.FromResult(false)); } var TypeLottery = new TypeLottery(message.Id, message.Name, message.Tens_Min, message.Bet_Min, message.Hit_Min, message.Hit_Max); var existingTypeLottery = _TypeLotteryRepository.GetById(TypeLottery.Id); if (existingTypeLottery != null && existingTypeLottery.Id != TypeLottery.Id) { //se o obj retornado nao for igual ao 'person' if (!existingTypeLottery.Equals(TypeLottery)) { Bus.RaiseEvent(new DomainNotification(message.MessageType, "O e-mail desta pessoa já está sendo usado!")); return(Task.FromResult(false)); } } _TypeLotteryRepository.Update(TypeLottery); if (Commit()) { Bus.RaiseEvent(new TypeLotteryUpdatedEvent(TypeLottery.Id, TypeLottery.Name, TypeLottery.Tens_Min, TypeLottery.Bet_Min, TypeLottery.Hit_Min, TypeLottery.Hit_Max)); } return(Task.FromResult(true)); }
public Task <bool> Handle(RegisterNewTypeLotteryCommand message, CancellationToken cancellationToken) { if (!message.IsValid()) { NotifyValidationErrors(message); return(Task.FromResult(false)); } var TypeLottery = new TypeLottery(Guid.NewGuid(), message.Name, message.Tens_Min, message.Bet_Min, message.Hit_Min, message.Hit_Max); if (_TypeLotteryRepository.GetById(TypeLottery.Id) != null) { Bus.RaiseEvent(new DomainNotification(message.MessageType, "O ID deste tipo de jogo já está sendo usado!")); return(Task.FromResult(false)); } _TypeLotteryRepository.Add(TypeLottery); if (Commit()) { Bus.RaiseEvent(new TypeLotteryRegisteredEvent(TypeLottery.Id, TypeLottery.Name, TypeLottery.Tens_Min, TypeLottery.Bet_Min, TypeLottery.Hit_Min, TypeLottery.Hit_Max)); } return(Task.FromResult(true)); }
public RegisterNewLotteryCommand(int concurse, DateTime dtconcurse, string game, int hit15, int hit14, int hit13, int hit12, int hit11, decimal shared15, decimal shared14, decimal shared13, decimal shared12, decimal shared11, DateTime dtnextconcurse, TypeLottery typeLottery) { Concurse = concurse; DtConcurse = dtconcurse; Game = game; Hit15 = hit15; Hit14 = hit14; Hit13 = hit13; Hit12 = hit12; Hit11 = hit11; Shared15 = shared15; Shared14 = shared14; Shared13 = shared13; Shared12 = shared12; Shared11 = shared11; DtNextConcurse = dtnextconcurse; TypeLottery = typeLottery; }
public UpdateLotteryCommand(Guid id, int concurse, DateTime dtconcurse, string game, int hit15, int hit14, int hit13, int hit12, int hit11, decimal shared15, decimal shared14, decimal shared13, decimal shared12, decimal shared11, DateTime dtnextconcurse, TypeLottery TypeLottery) { Id = id; Concurse = concurse; DtConcurse = dtconcurse; Game = game; Hit15 = hit15; Hit14 = hit14; Hit13 = hit13; Hit12 = hit12; Hit11 = hit11; Shared15 = shared15; Shared14 = shared14; Shared13 = shared13; Shared12 = shared12; Shared11 = shared11; DtNextConcurse = dtnextconcurse; TypeLottery = TypeLottery; }
internal static void SeedLotteryData(LoteriaFacilContext context) { string caminhoPadrao = Directory.GetCurrentDirectory(); string caminhoArquivo = Directory.GetCurrentDirectory().Remove(caminhoPadrao.LastIndexOf("\\")); string caminho = caminhoArquivo + @"\lotofacilDados.txt"; //string caminho =lotofacil; /* * Estrutura do Arquivo: * 0 - Num do Concurso * 1 - Data Concurso * 2~16 - Dezenas * 17 - Qtde de Pessoas 15 Acertos * 18 - Qtde de Pessoas 14 Acertos * 19 - Qtde de Pessoas 13 Acertos * 20 - Qtde de Pessoas 12 Acertos * 21 - Qtde de Pessoas 11 Acertos * 22 - Valor Rateio 15 Acertos * 23 - Valor Rateio 14 Acertos * 24 - Valor Rateio 13 Acertos * 25 - Valor Rateio 12 Acertos * 26 - Valor Rateio 11 Acertos */ TypeLottery tpl = context.TypeLottery.FirstOrDefault(); if (tpl != null && File.Exists(caminho)) { var texto = string.Empty; List <string> inserts = new List <string>(); StreamReader _strm = new StreamReader(caminho); while (!_strm.EndOfStream) { DateTime dataConcurso; string concurso; string dezenas; string qtdePesosas15Acertos; string qtdePesosas14Acertos; string qtdePesosas13Acertos; string qtdePesosas12Acertos; string qtdePesosas11Acertos; string valorRateio15Acertos; string valorRateio14Acertos; string valorRateio13Acertos; string valorRateio12Acertos; string valorRateio11Acertos; string linha = _strm.ReadLine(); string[] vet; if (!string.IsNullOrEmpty(linha)) { vet = linha.Split('|'); if (vet.Length == 27 || vet.Length == 26 || vet.Length == 28) { if (vet[1] != "") { concurso = vet[0]; dataConcurso = Convert.ToDateTime(vet[1]); if (vet[2].Length == 1) { vet[2] = 0 + vet[2]; } if (vet[3].Length == 1) { vet[3] = 0 + vet[3]; } if (vet[4].Length == 1) { vet[4] = 0 + vet[4]; } if (vet[5].Length == 1) { vet[5] = 0 + vet[5]; } if (vet[6].Length == 1) { vet[6] = 0 + vet[6]; } if (vet[7].Length == 1) { vet[7] = 0 + vet[7]; } if (vet[8].Length == 1) { vet[8] = 0 + vet[8]; } if (vet[9].Length == 1) { vet[9] = 0 + vet[9]; } if (vet[10].Length == 1) { vet[10] = 0 + vet[10]; } if (vet[11].Length == 1) { vet[11] = 0 + vet[11]; } if (vet[12].Length == 1) { vet[12] = 0 + vet[12]; } if (vet[13].Length == 1) { vet[13] = 0 + vet[13]; } if (vet[14].Length == 1) { vet[14] = 0 + vet[14]; } if (vet[15].Length == 1) { vet[15] = 0 + vet[15]; } if (vet[16].Length == 1) { vet[16] = 0 + vet[16]; } dezenas = vet[2] + "-" + vet[3] + "-" + vet[4] + "-" + vet[5] + "-" + vet[6] + "-" + vet[7] + "-" + vet[8] + "-" + vet[9] + "-" + vet[10] + "-" + vet[11] + "-" + vet[12] + "-" + vet[13] + "-" + vet[14] + "-" + vet[15] + "-" + vet[16]; qtdePesosas15Acertos = vet[17]; qtdePesosas14Acertos = vet[18]; qtdePesosas13Acertos = vet[19]; qtdePesosas12Acertos = vet[20]; qtdePesosas11Acertos = vet[21]; valorRateio15Acertos = vet[22]; valorRateio14Acertos = vet[23]; valorRateio13Acertos = vet[24]; valorRateio12Acertos = vet[25]; valorRateio11Acertos = vet[26]; var Acertos = new { Hits15 = Convert.ToInt32(qtdePesosas15Acertos.ToString()), Shared15 = Convert.ToDecimal(valorRateio15Acertos.ToString()), Hits14 = Convert.ToInt32(qtdePesosas14Acertos.ToString()), Shared14 = Convert.ToDecimal(valorRateio14Acertos.ToString()), Hits13 = Convert.ToInt32(qtdePesosas13Acertos.ToString()), Shared13 = Convert.ToDecimal(valorRateio13Acertos.ToString()), Hits12 = Convert.ToInt32(qtdePesosas12Acertos.ToString()), Shared12 = Convert.ToDecimal(valorRateio12Acertos.ToString()), Hits11 = Convert.ToInt32(qtdePesosas11Acertos.ToString()), Shared11 = Convert.ToDecimal(valorRateio11Acertos.ToString()), }; Lottery lottery = new Lottery() { Concurse = int.Parse(concurso), DtConcurse = dataConcurso, Game = Util.OrdenaDezenas(dezenas), Hit15 = Acertos.Hits15, Hit14 = Acertos.Hits14, Hit13 = Acertos.Hits13, Hit12 = Acertos.Hits12, Hit11 = Acertos.Hits11, Shared15 = Acertos.Shared15, Shared14 = Acertos.Shared14, Shared13 = Acertos.Shared13, Shared12 = Acertos.Shared12, Shared11 = Acertos.Shared11, DtNextConcurse = dataConcurso.DayOfWeek == DayOfWeek.Friday ? dataConcurso.AddDays(3) : dataConcurso.AddDays(2), TypeLotteryId = tpl.Id }; context.Lottery.Add(lottery); } } } } context.SaveChanges(); } }