public Bill updateLocalitiesSoccerGame(string code_client, DateTime date_bill, string way_pay, List <Locality> localities) { Bill bill = new Bill(); try { DAOService service = new DAOService(); List <Locality> list_loc = localities; if (list_loc != null && list_loc.Count >= 0 && code_client != null && !code_client.Equals("")) { SoccerGame soccerGame = new SoccerGame() { code_soccergame = list_loc[0].code_soccergame, localities = list_loc }; bill = service.generateBill(soccerGame, date_bill, code_client, way_pay); } else { bill = new Bill(); } } catch (Exception e) { bill = new Bill(); } return(bill); }
public async Task <CreateSoccerGameCommandResult> Handle(CreateSoccerGameCommand request, CancellationToken cancellationToken) { var chessGame = new SoccerGame(request.GameDate, request.Description, request.RegistrationEndDate); await _gameGameRepository.SaveGameAsync(chessGame); return(new CreateSoccerGameCommandResult(chessGame.Guid)); }
public SoccerGame getReportSoccerGame(string code_soccergame) { SoccerGame soccergame = new SoccerGame(); try { using (ticketpremiumEntities db = new ticketpremiumEntities()) { var aux = db.TEPAF_PARFUT.Find(code_soccergame); soccergame.code_soccergame = aux.TEPAF_CODIGO; soccergame.date_soccergame = aux.TEPAF_FECHA.ToString(); soccergame.local_team = aux.TEPAF_LOCAL; soccergame.visitor_team = aux.TEPAF_VISITA; soccergame.place = aux.TEPAF_LUGAR; var localities = aux.TELCP_LOCPTD; List <Locality> list_localities = new List <Locality>(); foreach (TELCP_LOCPTD aux_locality in localities) { list_localities.Add(new Locality() { code_locality = aux_locality.TELCP_CODIGO, code_soccergame = aux_locality.TEPAF_CODIGO, availability = aux_locality.TELCP_DISPON, price = (float)(aux_locality.TELCP_PRECIO * aux_locality.TELCP_DISPON) }); } soccergame.localities = list_localities; } } catch (Exception e) { soccergame = null; } return(soccergame); }
public ActionResult GetReport() { string codeSoccerGame = Request["code"]; using (WSTicket.WSTicketClient client = new WSTicket.WSTicketClient()) { SoccerGame soccerGame = client.getReportSoccerGame(codeSoccerGame); ViewBag.code = soccerGame.code_soccergame; return(View(soccerGame)); } }
// GET: Bills public ActionResult Buy() { string codeSoccerGame = Request["code"]; using (WSTicket.WSTicketClient client = new WSTicket.WSTicketClient()) { SoccerGame soccerGame = client.getSoccerGame(codeSoccerGame); ViewBag.clients = new SelectList(client.getClients().ToList(), "code_client", "name_client"); ViewBag.code = soccerGame.code_soccergame; return(View(soccerGame)); } }
void AgregarUnGolAJuego() { //Agregar un jugador al equipo /**using (var ctx = new SoccerAppContext()) * { * Team necaxa = ctx.Teams.Where(t => t.Name.Contains("Necaxa")).Include(t => t.Players).FirstOrDefault(); * necaxa.Players.Add(new Player { Name = "Player 01", DateOfBirth = DateTime.Now, Active = true, Number = 10 }); * * ctx.SaveChanges(); * }**/ //agregar un gol a un juego del torneo ID =4 using (var ctx = new SoccerAppContext()) { var tournament = ctx.Tournaments.Where(t => t.TournamentId == 4) .Include(t => t.Teams) .Include(t => t.Games) .FirstOrDefault(); if (tournament != null) { //consultamos el id del team //int necaxaId = tournament.Teams.FirstOrDefault(t => t.Name.Contains("Necaxa")).TeamId; Team necaxa = tournament.Teams.FirstOrDefault(t => t.Name.Contains("Necaxa")); //int necaxaId = necaxa.TeamId.Value; //consultamos los jugadores //var plyLts = ctx.Teams.Where(t => t.TeamId == necaxaId).Include(t => t.Players).SelectMany(t => t.Players).ToList(); var plyLts = necaxa.Players; // agregar un gol a juego SoccerGame soccerGame = tournament.Games.ElementAt(0); //soccerGame.Goals = new List<Goal>(); soccerGame.Goals.Add(new Goal { Scorer = plyLts.FirstOrDefault(), ScoringTime = 79 }); try { ctx.SaveChanges(); } catch (Exception ex) { Console.WriteLine("Error: {0}", ex.Message); if (ex.InnerException != null) { Console.WriteLine("Error {0}", ex.InnerException); } } } } }
public ActionResult Bill() { string codeClient = Request["clients"]; string codePayway = Request["payway"]; int quantityGeneral = 0; int quantityPalco = 0; int quantityTribuna = 0; if (Int32.TryParse(Request["GENERAL"], out int auxGeneral)) { quantityGeneral = auxGeneral; } if (Int32.TryParse(Request["PALCO"], out int auxPalco)) { quantityPalco = auxPalco; } if (Int32.TryParse(Request["TRIBUNA"], out int auxTribuna)) { quantityTribuna = auxTribuna; } string codeSoccerGame = Request["code"]; using (WSTicket.WSTicketClient client = new WSTicket.WSTicketClient()) { SoccerGame soccerGame = client.getSoccerGame(codeSoccerGame); List <Locality> listLocalities = soccerGame.localities.ToList(); foreach (Locality l in listLocalities) { if (l.code_locality.Equals("GENERAL")) { l.availability = quantityGeneral; } if (l.code_locality.Equals("PALCO")) { l.availability = quantityPalco; } if (l.code_locality.Equals("TRIBUNA")) { l.availability = quantityTribuna; } } Bill billCreated = client.updateLocalitiesSoccerGame(codeClient, DateTime.Now, codePayway, listLocalities.ToArray()); float subtotal = billCreated.total / 1.12f; ViewBag.subtotal = subtotal; ViewBag.iva = subtotal * 0.12f; return(View(billCreated)); } }
public SoccerGame getSoccerGame(string code_soccergame) { SoccerGame soccerGame; try { DAOService service = new DAOService(); soccerGame = service.getSoccerGame(code_soccergame); } catch (Exception e) { soccerGame = new SoccerGame(); } return(soccerGame); }
public async Task <ActionResult> GetReport() { string codeSoccerGame = Request["code"]; string ip = "192.168.1.114"; var httpClient = new HttpClient(); string urlEnviada = "http://" + ip + ":8080/TicketPremium_Server_REST/WSTicket/getReportSoccerGame/" + codeSoccerGame; var json = await httpClient.GetStreamAsync(urlEnviada); SoccerGame soccerGame = JsonConvert.DeserializeObject <SoccerGame>(json.ToString()); ViewBag.code = soccerGame.code_soccergame; return(View(soccerGame)); }
private SoccerGame updateLocalitiesSoccerGame(SoccerGame client_soccergame) { SoccerGame result_soccergame = getSoccerGame(client_soccergame.code_soccergame); if (result_soccergame == null) { return(null); } List <Locality> list_location = new List <Locality>(); try { foreach (Locality aux in client_soccergame.localities) { TELCP_LOCPTD telcpLocptd = null; using (ticketpremiumEntities db = new ticketpremiumEntities()) { telcpLocptd = db.TELCP_LOCPTD.Find(aux.code_locality, aux.code_soccergame); } if (telcpLocptd != null && ((telcpLocptd.TELCP_CANBAS - telcpLocptd.TELCP_DISPON) >= aux.availability) && aux.availability > 0) { TELCP_LOCPTD locality = telcpLocptd; locality.TELCP_DISPON = locality.TELCP_DISPON + aux.availability; if (updateLocality(locality)) { list_location.Add(new Locality() { code_locality = locality.TELCP_CODIGO, code_soccergame = locality.TEPAF_CODIGO, availability = aux.availability, price = (float)(aux.availability * locality.TELCP_PRECIO) }); } } } result_soccergame.localities = list_location; }catch (Exception e) { result_soccergame = null; } return(result_soccergame); }
// GET: Bills public async Task <ActionResult> Buy() { string ip = "192.168.1.114"; var httpClient = new HttpClient(); string codeSoccerGame = Request["code"]; string urlEnviada = "http://" + ip + ":8080/TicketPremium_Server_REST/WSTicket/getSoccerGame/" + codeSoccerGame; var json = await httpClient.GetStreamAsync(urlEnviada); SoccerGame soccerGame = JsonConvert.DeserializeObject <SoccerGame>(json.ToString()); string urlEnviada2 = "http://" + ip + ":8080/TicketPremium_Server_REST/WSTicket/getClients/"; var json2 = await httpClient.GetStreamAsync(urlEnviada2); List <Client> clientList = JsonConvert.DeserializeObject <List <Client> >(json2.ToString()); ViewBag.clients = new SelectList(clientList, "code_client", "name_client"); ViewBag.code = soccerGame.code_soccergame; return(View(soccerGame)); }
public async Task IfGameIsAlreadyFinished_ItShouldReturnNull() { // Arrange var mockUnitOfWork = new Mock <IUnitOfWork>(); var mockGame = new SoccerGame() { Id = 1, ReporterId = Guid.NewGuid().ToString(), GameStatus = GameStatus.Finished }; _gameService = new GameService(mockUnitOfWork.Object); mockUnitOfWork.Setup(p => p.GameRepository.Update(mockGame)); // Act var result = await _gameService.StopGame(mockGame); // Assert Assert.AreEqual(null, result); }
public async Task IfGameHasNotStarted_ItShouldReturn_InProgress() { // Arrange var mockUnitOfWork = new Mock <IUnitOfWork>(); var userId = Guid.NewGuid().ToString(); var mockGame = new SoccerGame() { Id = 1, ReporterId = Guid.NewGuid().ToString(), GameStatus = GameStatus.NotStarted }; _gameService = new GameService(mockUnitOfWork.Object); mockUnitOfWork.Setup(p => p.GameRepository.Update(mockGame)); // Act var result = await _gameService.StartGame(mockGame, userId); // Assert Assert.AreEqual(GameStatus.InProgress, result.GameStatus); }
public async Task <ActionResult> Bill() { string codeClient = Request["clients"]; string codePayway = Request["payway"]; int quantityGeneral = 0; int quantityPalco = 0; int quantityTribuna = 0; if (Int32.TryParse(Request["GENERAL"], out int auxGeneral)) { quantityGeneral = auxGeneral; } if (Int32.TryParse(Request["PALCO"], out int auxPalco)) { quantityPalco = auxPalco; } if (Int32.TryParse(Request["TRIBUNA"], out int auxTribuna)) { quantityTribuna = auxTribuna; } string codeSoccerGame = Request["code"]; string ip = "192.168.1.114"; var httpClient = new HttpClient(); string urlEnviada = "http://" + ip + ":8080/TicketPremium_Server_REST/WSTicket/getSoccerGame/" + codeSoccerGame; var json = await httpClient.GetStreamAsync(urlEnviada); SoccerGame soccerGame = JsonConvert.DeserializeObject <SoccerGame>(json.ToString()); List <Locality> listLocalities = soccerGame.localities.ToList(); foreach (Locality l in listLocalities) { if (l.code_locality.Equals("GENERAL")) { l.availability = quantityGeneral; } if (l.code_locality.Equals("PALCO")) { l.availability = quantityPalco; } if (l.code_locality.Equals("TRIBUNA")) { l.availability = quantityTribuna; } } string urlEnviada2 = "http://" + ip + ":8080/TicketPremium_Server_REST/WSTicket/updateLocalitiesSoccerGame/"; HttpClient client = new HttpClient(); Bill billCreated = await httpClient.PostAsync("AddNewArticle", new SoccerGame { code_soccergame = "", code_payway = codePayway, localities = listLocalities }); float subTotal = billCreated.total / 1.12f; ViewBag.subtotal = subTotal; ViewBag.iva = billCreated.total - subTotal; return(View(billCreated)); }
public List <Bill> getClientBills(string code_client) { List <Bill> list_result = new List <Bill>(); try { List <Bill> billList = null; using (ticketpremiumEntities db = new ticketpremiumEntities()) { billList = (from d in db.TEFAC_FACTUR where d.TECLI_CODIGO == code_client select new Bill { code_client = d.TECLI_CODIGO, name_client = d.TECLI_CLIENT.TECLI_NOMBRE, code_bill = d.TEFAC_CODIGO, date_bill = d.TEFAC_FECHA.ToString(), way_pay = d.TEFAC_MODPAG, total = (float)d.TEFAC_TOTAL }).ToList(); } if (billList != null) { for (int i = 0; i < billList.Count; i++) { SoccerGame soccer_game = new SoccerGame(); List <TEDEF_DETFAC> list_detfac = new List <TEDEF_DETFAC>(); int aux_code_bill = billList[i].code_bill; TEPAF_PARFUT aux_soccergame = new TEPAF_PARFUT(); using (ticketpremiumEntities db = new ticketpremiumEntities()) { list_detfac = (from d in db.TEDEF_DETFAC where d.TEFAC_CODIGO == aux_code_bill select d).ToList(); aux_soccergame = db.TEPAF_PARFUT.Find(list_detfac[0].TEPAF_CODIGO); } soccer_game = new SoccerGame() { code_soccergame = aux_soccergame.TEPAF_CODIGO, local_team = aux_soccergame.TEPAF_LOCAL, visitor_team = aux_soccergame.TEPAF_VISITA, place = aux_soccergame.TEPAF_LUGAR, date_soccergame = aux_soccergame.TEPAF_FECHA.ToString() }; List <Locality> list_localities = new List <Locality>(); foreach (TEDEF_DETFAC aux in list_detfac) { Locality new_locality = new Locality() { code_locality = aux.TELCP_CODIGO, code_soccergame = aux.TEPAF_CODIGO, availability = aux.TEDEF_CANTID, price = (float)aux.TEDEF_SUBTOT }; list_localities.Add(new_locality); } soccer_game.localities = list_localities; billList[i].soccer_game = soccer_game; } list_result = billList; } else { list_result = null; } } catch (Exception e) { list_result = null; } return(list_result); }
public Bill generateBill(SoccerGame soccerGame, DateTime date_bill, string code_client, string mod_pag) { Bill bill = null; try { TECLI_CLIENT client = null; using (var db = new ticketpremiumEntities()) { client = db.TECLI_CLIENT.Find(code_client); } if (client != null) { SoccerGame result_soccergame = updateLocalitiesSoccerGame(soccerGame); if (result_soccergame != null) { int bill_code_saved = 0; float total = 0; using (var db = new ticketpremiumEntities()) { TEFAC_FACTUR aux_bill = new TEFAC_FACTUR(); aux_bill.TECLI_CODIGO = client.TECLI_CODIGO; aux_bill.TEFAC_FECHA = date_bill; aux_bill.TEFAC_MODPAG = mod_pag; foreach (Locality locality in result_soccergame.localities) { total += locality.price; } aux_bill.TEFAC_TOTAL = total; db.TEFAC_FACTUR.Add(aux_bill); db.SaveChanges(); bill_code_saved = aux_bill.TEFAC_CODIGO; } if (bill_code_saved > 0) { List <Locality> localities_bill = new List <Locality>(); foreach (Locality locality in result_soccergame.localities) { TEDEF_DETFAC tedef_detfac = new TEDEF_DETFAC(); tedef_detfac.TELCP_CODIGO = locality.code_locality; tedef_detfac.TEPAF_CODIGO = locality.code_soccergame; tedef_detfac.TEFAC_CODIGO = bill_code_saved; tedef_detfac.TEDEF_CANTID = locality.availability; tedef_detfac.TEDEF_SUBTOT = locality.price; if (createDetail(tedef_detfac)) { localities_bill.Add(locality); } } result_soccergame.localities = localities_bill; bill = new Bill(); bill.code_client = client.TECLI_CODIGO; bill.name_client = client.TECLI_NOMBRE; bill.code_bill = bill_code_saved; bill.date_bill = date_bill.ToString(); bill.way_pay = mod_pag; bill.total = total; bill.soccer_game = result_soccergame; } else { bill = null; } } else { bill = null; } } else { bill = null; } } catch (Exception e) { bill = null; } return(bill); }
void AgregarJuegoATorneo() { //crear un torneo con dos equipos /*using (var ctx = new SoccerAppContext()) * { * Tournament t = new Tournament * { * Name = "Liga MX", * CreationDate = DateTime.Now, * Teams = new List<Team>() * }; * * t.Teams.Add(new Team { Name = "Necaxa", Active = true, CountryName = "MX", Founded = DateTime.Now }); * t.Teams.Add(new Team { Name = "Guadalajara", Active = true, CountryName = "MX", Founded = DateTime.Now }); * t.Teams.Add(new Team { Name = "Monterrey", Active = true, CountryName = "MX", Founded = DateTime.Now }); * * ctx.Tournaments.Add(t); * ctx.SaveChanges(); * }*/ //agregar un juego al torneo using (var ctx = new SoccerAppContext()) { //Consulta el torneo var tournameLst = from t in ctx.Tournaments where t.Name.CompareTo("Liga MX") == 0 select t; var tournament = tournameLst.FirstOrDefault(); if (tournament != null) { //consultar los equipos var necTeam = ctx.Teams.FirstOrDefault(team => team.Name.CompareTo("Necaxa") == 0); var guaTeam = ctx.Teams.FirstOrDefault(team => team.Name.CompareTo("Guadalajara") == 0); //var teamLst = ctx.Tournaments.Where(t => t.TournamentId == tournament.TournamentId).Include(t => t.Teams).SelectMany(x => x.Teams).ToList(); //crear el juego SoccerGame scg = new SoccerGame { Date = DateTime.Now, LocalTeam = necTeam, VisitTeam = guaTeam, GameNumber = 3 }; try { tournament.CreationDate = DateTime.Now; tournament.Games = new List <SoccerGame>(); tournament.Games.Add(scg); ctx.SaveChanges(); } catch (Exception ex) { Console.WriteLine("Error: {0}", ex.Message); if (ex.InnerException != null) { Console.WriteLine("Error {0}", ex.InnerException); } } } } }