public async Task <IActionResult> NewGoal(ViewModel.NewGoal newGoal, int gameId) { if (!TimeSpan.TryParse(newGoal.Hora, out TimeSpan resultado)) { await newGoal.LoadCombos(_config, _token, gameId); ViewBag.MsgError = "Hora inválida."; ViewBag.GameID = gameId; return(View(newGoal)); } using (var http = new HttpClient()) { http.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", _token.Token); Gol gol = new Gol() { JogadorId = newGoal.Jogador, TimeId = newGoal.Time, JogoId = gameId, Hora = TimeSpan.Parse(newGoal.Hora) }; var response = await http.PostAsync($"{path}/goal", new StringContent(JsonConvert.SerializeObject(gol), Encoding.UTF8, "application/json")); return(RedirectToAction("Index", new { id = gameId })); } }
public List <Gol> LeerGoles() { OracleCommand cmd; List <Gol> goles = new List <Gol>(); Gol gol; cmd = new OracleCommand("SELECT * FROM GOL", _bd); cmd.CommandType = System.Data.CommandType.Text; try { OracleDataReader aux = cmd.ExecuteReader(); while (aux.Read()) { int minuto = Convert.ToInt32(aux["MINUTO"]); string jugador = aux["JUGADOR_GOL"].ToString(); string equipoLocal = aux["EQUIPO_L_GOL"].ToString(); string equipoVisitante = aux["EQUIPO_V_GOL"].ToString(); DateTime fecha = Convert.ToDateTime(aux["FECHA_GOL"]); gol = new Gol(minuto, jugador, equipoLocal, equipoVisitante, fecha); goles.Add(gol); } } catch (Exception ex) { return(goles); } return(goles); }
public ActionResult DeleteConfirmed(int id) { Gol gol = db.Gol.Find(id); db.Gol.Remove(gol); db.SaveChanges(); return(RedirectToAction("Index")); }
public int Añadir(Gol g) { int filas_almacenadas; filas_almacenadas = bd.AñadirGol(g); _goles.Add(g); return(filas_almacenadas); }
public int Borrar(Gol g) { int filas_almacenadas; filas_almacenadas = bd.BorrarGol(g); _goles.Remove(g); return(filas_almacenadas); }
// GET: EventoGol public ActionResult Index() { Gol gol = new Gol(); gol.Jogo.Id = Guid.Parse("83c8ff15-7dad-401e-ac54-08bf93bb028c"); gol.Clube.Id = Guid.Parse("ea99c667-b531-43f9-986c-3e580af15165"); EventHandler ev = OnGolDeContra(gol); return(View()); }
public ActionResult Edit([Bind(Include = "IDGol,iCodJogadorSumula,iQuantidade,dDataCadastro")] Gol gol) { if (ModelState.IsValid) { db.Entry(gol).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.iCodJogadorSumula = new SelectList(db.JogadorSumula, "IDJogadorSumula", "IDJogadorSumula", gol.iCodJogadorSumula); return(View(gol)); }
static void Main(string[] args) { TorneoDeFutbol superliga = new TorneoDeFutbol(); Arbitro laverni = new Arbitro(); laverni.Edad = 50; laverni.Nacionalidad = "Argentino"; laverni.Nacionalidad = "Argentino"; laverni.Nombre = "Saul Laverni"; string ciudad = "La Plata"; Equipo estudiantes = GetLocal(); Equipo gimnasia = GetVisitante(); if (superliga.NuevoPartido(laverni, ciudad, estudiantes, gimnasia)) { Console.WriteLine("Se juega el clasico de la plata"); Tarjeta primerPolemica = new Tarjeta(gimnasia.Jugadores.Find(x => x.Nombre.Contains("Correa")), 18, ColorTarjeta.Amarilla); Console.WriteLine(primerPolemica.ObtenerDescripcionIncidencia()); Gol primerGol = new Gol(gimnasia.Jugadores.Find(x => x.Nombre.Contains("Correa")), false, 22, false); Console.WriteLine(primerGol.ObtenerDescripcionIncidencia()); Tarjeta segundaPolemica = new Tarjeta(gimnasia.Jugadores.Find(x => x.Nombre.Contains("Oreja")), 37, ColorTarjeta.Amarilla); Console.WriteLine(segundaPolemica.ObtenerDescripcionIncidencia()); Tarjeta terceraPolemica = new Tarjeta(gimnasia.Jugadores.Find(x => x.Nombre.Contains("Oreja")), 37, ColorTarjeta.Roja); terceraPolemica.TarjetaAsociada = segundaPolemica; Console.WriteLine(terceraPolemica.ObtenerDescripcionIncidencia()); Gol segundoGol = new Gol(estudiantes.Jugadores.Find(x => x.Nombre.Contains("Aguirregaray")), false, 60, false); Console.WriteLine(segundoGol.ObtenerDescripcionIncidencia()); List <Incidencia> incidencias = new List <Incidencia>(); incidencias.Add(primerPolemica); incidencias.Add(primerGol); incidencias.Add(segundaPolemica); incidencias.Add(terceraPolemica); incidencias.Add(segundoGol); incidencias.ForEach(incidencia => superliga.Partidos[0].AgregarIncidencia(primerPolemica)); ResumenPartido resumen = superliga.Partidos[0].ObtenerResultadoFinal(); Console.WriteLine("Resumen del partido"); Console.WriteLine(resumen.EquipoLocal.Nombre + " " + resumen.GolesLocal + " - " + resumen.GolesVisitante + " " + resumen.EquipoVisitante.Nombre); } else { Console.WriteLine("Algo está mal"); } }
// GET: Gol/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Gol gol = db.Gol.Find(id); if (gol == null) { return(HttpNotFound()); } return(View(gol)); }
// GET: Gol/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Gol gol = db.Gol.Find(id); if (gol == null) { return(HttpNotFound()); } ViewBag.iCodJogadorSumula = new SelectList(db.JogadorSumula, "IDJogadorSumula", "IDJogadorSumula", gol.iCodJogadorSumula); return(View(gol)); }
public async Task <IActionResult> Post([FromBody] Gol gol) { if (ModelState.IsValid) { _context.Gols.Add(gol); await _context.SaveChangesAsync(); await NotifyNewGoal(gol.Id); return(Created($"api/gol/{gol.Id}", gol)); } else { return(BadRequest(ModelState)); } }
private void buttGol_Click(object sender, EventArgs e) { int hrac = Int32.Parse(textGolHrac.Text); Hrac h = new Hrac() { HracId = hrac }; Gol g = new Gol() { Hrac = h }; z.ZapisGol(g); textGolHrac.Text = ""; }
public int Insert(Gol g) { using (db.GetConnection()) { db.Connect(); OracleCommand command = db.CreateCommand(insert); command.Parameters.AddWithValue(":Hrac", g.Hrac.HracId); var zap = new ZapasyTable(); int maximum = zap.PosledniZapas(); command.Parameters.AddWithValue(":Zapas", maximum); //command.Parameters.AddWithValue(":Zapas", g.Zapas.ZapasId); int ret = db.ExecuteNonQuery(command); return(ret); } }
private static Collection <Gol> Read(SqlDataReader reader) { var goly = new Collection <Gol>(); while (reader.Read()) { int i = -1; Gol gol = new Gol(); gol.Hrac = new Hrac(); gol.Hrac.IdHrac = reader.GetInt32(++i); gol.Hrac.Jmeno = reader.GetString(++i); gol.PocetGolu = reader.GetInt32(++i); goly.Add(gol); } return(goly); }
public ActionResult JogadorSumula(JogadorSumulaGolCartao jogadorSumulaGolCartao) { if (jogadorSumulaGolCartao == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } JogadorSumula jogadorsumula = db.JogadorSumula.Find(jogadorSumulaGolCartao.IDJogadorSumula); if (jogadorsumula == null) { return(HttpNotFound()); } using (var transaction = db.Database.BeginTransaction()) { try { // TipoCartao tipoCartao = (TipoCartao)Enum.ToObject(typeof(TipoCartao), iCartao); Cartao cartao = db.Cartao.Where(p => p.iCodJogadorSumula == jogadorsumula.IDJogadorSumula).FirstOrDefault(); db.Entry(cartao).State = EntityState.Modified; db.Entry(cartao).Property("dDataCadastro").IsModified = false; cartao.iTipoCartao = jogadorSumulaGolCartao.iCartao; db.SaveChanges(); Gol gol = db.Gol.Where(p => p.iCodJogadorSumula == jogadorsumula.IDJogadorSumula).FirstOrDefault(); db.Entry(gol).State = EntityState.Modified; db.Entry(gol).Property("dDataCadastro").IsModified = false; gol.iQuantidade = jogadorSumulaGolCartao.iGol; db.SaveChanges(); transaction.Commit(); } catch (Exception ex) { ex.Message.ToString(); transaction.Rollback(); } } return(RedirectToAction("Create/" + jogadorSumulaGolCartao.IDSumula).ComMensagem("Operação realizada com sucesso.", "alert-success")); }
public int AñadirGol(Gol g) { string sql = "INSERT INTO GOL VALUES (" + "" + g.Minuto + ",'" + g.Jugador + "','" + g.EquipoLocal + "'," + "'" + g.EquipoVisitante + "','" + g.Fecha + "');"; OracleCommand cmd = _bd.CreateCommand(); cmd.CommandText = sql; cmd.CommandType = System.Data.CommandType.Text; try { cmd.ExecuteNonQuery(); } catch (Exception e) { return(0); } return(1); }
public int BorrarGol(Gol g) { string sql = "DELETE FROM GOL " + "WHERE minuto = " + g.Minuto + " AND JUGADOR_GOL = '" + g.Jugador + "' " + "AND EQUIPO_L_GOL = '" + g.EquipoLocal + "' " + "AND EQUIPO_V_GOL = '" + g.EquipoVisitante + "' AND FECHA_GOL = '" + g.Fecha + "'"; OracleCommand cmd = _bd.CreateCommand(); cmd.CommandText = sql; cmd.CommandType = System.Data.CommandType.Text; try { cmd.ExecuteNonQuery(); } catch (Exception e) { return(0); } return(1); }
public static List <Gol> getGolList() { List <Gol> GolDataList = new List <Gol>(); Gol GolData; Utils.adoDAL ado = new Utils.adoDAL(); try { ado.Conectar(); ado.CrearComando(@" SELECT idGol, GolNo FROM Goles WHERE Active = 1 "); DbDataReader reader = ado.EjecutarConsulta(); while (reader.Read()) { GolData = new Gol { idGol = Convert.ToInt32(reader["idGol"]), GolNo = Convert.ToString(reader["GolNo"]) }; GolDataList.Add(GolData); } } catch (SqlException sqlEx) { } catch (Exception ex) { } finally { ado.Desconectar(); } return(GolDataList); }
public static Collection <Gol> Read(OracleDataReader reader) { var data = new Collection <Gol>(); while (reader.Read()) { int i = -1; var goly = new Gol { GolId = reader.GetInt32(++i), Hrac = new Hrac { HracId = reader.GetInt32(++i) }, Zapas = new Zapas { ZapasId = reader.GetInt32(++i) } }; data.Add(goly); } return(data); }
protected void Page_Load(object sender, EventArgs e) { var oid = 6; con.Open(); var list = new List <Gol>(); var gols = new SqlCommand("select flower , j.gol, Darajeh.dar , orders.priority from order_details " + "inner join Darajeh on order_details.brand = Darajeh.ID " + "inner join orders on order_details.order_id = orders.id " + "left join(SELECT flower_entry.flower_name + ' / ' + flower_colors.flow_color + ' / ' " + "+ flower_colortypes.flow_colortype + ' / ' + flower_formats.flow_format AS gol, flower_entry.id " + "FROM flower_depot.dbo.flower_entry INNER JOIN flower_depot.dbo.flower_colors ON " + "flower_depot.dbo.flower_entry.flower_color = flower_depot.dbo.flower_colors.flowcolor_id INNER JOIN " + "flower_depot.dbo.flower_colortypes ON flower_depot.dbo.flower_entry.flower_colortype = " + "flower_depot.dbo.flower_colortypes.colortype_id INNER JOIN flower_depot.dbo.flower_formats " + "ON flower_depot.dbo.flower_entry.flower_format = " + "flower_depot.dbo.flower_formats.flowformat_id) as j on order_details.flower = j.id " + "where order_details.order_id = " + oid + " group by flower , gol ,priority , Darajeh.dar", con); var r = gols.ExecuteReader(); while (r.Read()) { list.Add(new Gol() { Id = Convert.ToInt32(r["flower"]), Name = r["gol"].ToString(), Darage = r["dar"].ToString(), Priority = r["priority"].ToString() }); } con.Close(); var l = new List <Gol>(); foreach (var flow in list) { var g = new Gol { Id = flow.Id, Name = flow.Name, Darage = flow.Darage, Priority = flow.Priority }; con.Open(); var items = new SqlCommand("select Item.nam, sum(tedad) as tedad from( (SELECT order_details.flower, dbo.Item.ID as nam, " + "dbo.Item.TDK * order_details.[count] as tedad FROM dbo.order_details " + "INNER JOIN dbo.Item ON dbo.order_details.item_id = dbo.Item.ID WHERE(dbo.order_details.order_id = " + oid + ") AND " + "(dbo.order_details.item_id <> 0) AND(dbo.Item.ser = 0) and order_details.box = 1) union all " + "(SELECT order_details.flower, dbo.Item.ID as nam, order_details.[count] as tedad FROM dbo.order_details " + "INNER JOIN dbo.Item ON dbo.order_details.item_id = dbo.Item.ID WHERE(dbo.order_details.order_id = " + oid + ") AND " + "(dbo.order_details.item_id <> 0) AND(dbo.Item.ser = 0) and order_details.box = 0) union all " + "((SELECT order_details.flower, dbo.RizSer.idI as nam, (dbo.RizSer.ted * dbo.Item.TDK) * order_details.[count] AS tedad " + "FROM dbo.RizSer INNER JOIN dbo.Item ON dbo.RizSer.idS = dbo.Item.idser INNER JOIN dbo.order_details ON " + "dbo.Item.ID = dbo.order_details.item_id WHERE(dbo.order_details.order_id = " + oid + ") AND(dbo.order_details.item_id <> 0) " + "AND(dbo.Item.ser = 1) AND(dbo.order_details.box = 1))) union all(SELECT dbo.order_details.flower, dbo.RizSer.idI AS nam, " + "dbo.RizSer.ted* dbo.order_details.count AS tedad FROM dbo.order_details INNER JOIN " + "dbo.RizSer ON dbo.order_details.service_id = dbo.RizSer.idS LEFT OUTER JOIN dbo.Item ON dbo.order_details.service_id = dbo.Item.idser " + "WHERE (dbo.order_details.order_id = " + oid + ") AND(dbo.order_details.service_id <> 0) AND(dbo.order_details.item_id = 0) AND(dbo.Item.low30 IS NULL)) " + "union all(SELECT dbo.order_details.flower, dbo.RizSer.idI AS nam, dbo.order_details.count* dbo.Item.TDK* dbo.RizSer.ted AS tedad " + "FROM dbo.order_details INNER JOIN dbo.Item ON dbo.order_details.service_id = dbo.Item.idser INNER JOIN " + "dbo.RizSer ON dbo.Item.idser = dbo.RizSer.idS WHERE (dbo.order_details.order_id = " + oid + ") AND(dbo.order_details.box = 1) " + "AND(dbo.order_details.service_id <> 0)))i INNER JOIN dbo.Item ON i.nam = dbo.Item.ID where flower = " + flow.Id + " group by i.flower , Item.nam ", con); var d = items.ExecuteReader(); while (d.Read()) { g.Items.Add(new Item() { Name = d["nam"].ToString(), Tedad = d["tedad"].ToString() }); } l.Add(g); con.Close(); } }
public void ZapisGol(Gol g) { GolyTable golyTable = new GolyTable(); golyTable.Insert(g); }
public IActionResult EditGolActionResult([FromBody] Gol gol) { return(Json(gol)); }
public ActionResult CreateJogador([Bind(Include = "IDJogadorSumula,IDJogadorInscrito,IDSumula,iNumCamisa,dDataCadastro")] JogadorSumula jogadorSumula, int?IDInscrito) { if (ModelState.IsValid) { try { if (jogadorSumula.iNumCamisa != 0) { if (jogadorSumula.iNumCamisa < 0) { return(RedirectToAction("Create/" + jogadorSumula.IDSumula).ComMensagem("O número da camisa não pode ser menor que 0.", "alert-warning")); } else { if (IDInscrito != null) { if (db.JogadorSumula.Where(p => p.iNumCamisa == jogadorSumula.iNumCamisa && p.Sumula.PartidaCampeonato.IDInscrito1 == IDInscrito && p.IDSumula == jogadorSumula.IDSumula).ToList().Count > 0) { return(RedirectToAction("Create/" + jogadorSumula.IDSumula).ComMensagem("Já existe jogador cadastrado com esta numeração.", "alert-warning")); } } } using (var transaction = db.Database.BeginTransaction()) { try { db.JogadorSumula.Add(jogadorSumula); db.SaveChanges(); Cartao cartao = new Cartao(); cartao.iCodJogadorSumula = jogadorSumula.IDJogadorSumula; cartao.iTipoCartao = TipoCartao.Nenhum; db.Cartao.Add(cartao); db.SaveChanges(); Gol gol = new Gol(); gol.iCodJogadorSumula = jogadorSumula.IDJogadorSumula; gol.iQuantidade = 0; db.Gol.Add(gol); db.SaveChanges(); transaction.Commit(); } catch (Exception ex) { ex.Message.ToString(); transaction.Rollback(); } } } else { return(RedirectToAction("Create/" + jogadorSumula.IDSumula).ComMensagem("Número da camisa é obrigatório.", "alert-warning")); } } catch (DbEntityValidationException dbEx) { foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { System.Console.WriteLine("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage); } } return(View().ComMensagem("Erro ao realizar a operação.", "alert-danger")); } } return(RedirectToAction("Create/" + jogadorSumula.IDSumula).ComMensagem("Operação realizada com sucesso.", "alert-success")); }
private EventHandler OnGolDeContra(Gol gol) { var jogo = (from j in Db.Jogo.Include("Clube") select j).Where(p => p.Id == gol.Jogo.Id && gol.Clube.Id == p.Id); return(null); }
public IActionResult SearchInGol(string name, string code, int flowerId) { string farsi1 = "", farsi2 = ""; if (name != null) { farsi1 = name.Replace("ک", "ك").Replace("ی", "ي").Replace("ة", "ه"); farsi2 = name.Replace("ك", "ک").Replace("ي", "ی").Replace("ه", "ة"); } con.Flower.Open(); var listGol = new List <Gol>(); var gol = new Gol(); var cmd = new SqlCommand("SELECT dbo.flower_colors.flow_color, dbo.flower_colortypes.flow_colortype, flower_entry.id, " + "dbo.flower_formats.flow_format, dbo.flower_customers.customer_name, dbo.flower_companies.company_name " + ", flower_entry.flower_name, flower_entry.flower_code, flower_entry.enter_date " + ", flower_entry.comment FROM dbo.flower_entry INNER JOIN " + "dbo.flower_colors ON dbo.flower_entry.flower_color = dbo.flower_colors.flowcolor_id INNER JOIN " + "dbo.flower_colortypes ON dbo.flower_entry.flower_colortype = dbo.flower_colortypes.colortype_id INNER JOIN " + "dbo.flower_formats ON dbo.flower_entry.flower_format = dbo.flower_formats.flowformat_id INNER JOIN " + "dbo.flower_customers ON dbo.flower_entry.customer_name = dbo.flower_customers.customer_id INNER JOIN " + "dbo.flower_companies ON dbo.flower_entry.company_name = dbo.flower_companies.company_id " + "where " + (flowerId != 0 ? " flower_entry.id = " + flowerId + " " : "(flower_entry.flower_name like N'%" + name + "%' or '%" + name + "%' = '') or " + "(flower_entry.flower_name like N'%" + farsi1 + "%' or '%" + farsi1 + "%' = '') or " + "(flower_entry.flower_name like N'%" + farsi2 + "%' or '%" + farsi2 + "%' = '') or " + "(flower_entry.flower_code like N'%" + code + "%' or '%" + code + "%' = '')"), con.Flower); var rd = cmd.ExecuteReader(); while (rd.Read()) { if (flowerId != 0) { gol.Id = Convert.ToInt32(rd["id"]); gol.GolName = rd["flower_name"].ToString(); gol.Color = rd["flow_color"].ToString(); gol.ColorType = rd["flow_colortype"].ToString(); gol.Format = rd["flow_format"].ToString(); gol.Code = rd["flower_code"].ToString(); gol.EnterDate = rd["enter_date"].ToString(); gol.Customer = rd["customer_name"].ToString(); gol.Company = rd["company_name"].ToString(); gol.Comment = rd["comment"].ToString(); } else { listGol.Add(new Gol() { Id = Convert.ToInt32(rd["id"]), GolName = rd["flower_name"].ToString(), Color = rd["flow_color"].ToString(), ColorType = rd["flow_colortype"].ToString(), Format = rd["flow_format"].ToString(), Code = rd["flower_code"].ToString(), EnterDate = rd["enter_date"].ToString(), Customer = rd["customer_name"].ToString(), Company = rd["company_name"].ToString(), Comment = rd["comment"].ToString() }); } } con.Flower.Close(); return(flowerId != 0 ? Json(gol) : Json(listGol)); }