internal void Save(Evento e)
        {
            PlaceMyBetContext context = new PlaceMyBetContext();

            context.Eventos.Add(e);
            context.SaveChanges();
        }
Beispiel #2
0
        /*internal mercadoDTO RetrieveDTO()
         * {
         *  return null;
         *  //Devuelve todos los registros
         *  //MySqlConnection con = Connect();
         *  //MySqlCommand command = con.CreateCommand();
         *  //command.CommandText = "select * from mercado";
         *
         *  //con.Open();
         *  //MySqlDataReader res = command.ExecuteReader();
         *
         *  //mercadoDTO m = null;
         *
         *      //Cada vez que ecuentra un objeto lo añade al list
         *      //List<mercadoDTO> mercados = new List<mercadoDTO>();
         *
         *      ////Devolver objeto mercado. Se devolvera un registro
         *      /*if (res.Read())
         *      {
         *          m = new mercadoDTO(res.GetString(0), res.GetDecimal(1), res.GetDecimal(2));
         *      }
         *
         *      con.Close();
         *      return m;
         *
         * }*/

        internal void SaveMercado(Mercado Merc)
        {
            PlaceMyBetContext context = new PlaceMyBetContext();

            context.Mercados.Add(Merc);
            context.SaveChanges();
        }
 internal void Delete(int id)
 {
     using (PlaceMyBetContext context = new PlaceMyBetContext())
     {
         Evento e = context.Eventos
                    .Where(s => s.EventoId == id)
                    .FirstOrDefault();
         context.Attach(e);
         context.Remove(e);
         context.SaveChanges();
     }
 }
        /* Fin Ejercicio 1 */



        internal void Update(int ID_Equipo, string Equipo_Local, string Equipo_visitante)
        {
            using (PlaceMyBetContext context = new PlaceMyBetContext())
            {
                Evento evento = context.Eventos
                                .Where(s => s.EventoId == ID_Equipo)
                                .FirstOrDefault();
                evento.Equipo_Local     = Equipo_Local;
                evento.Equipo_visitante = Equipo_visitante;
                context.Update(evento);
                context.SaveChanges();
            }
        }
Beispiel #5
0
 /*** Ejercicio 2 ***/
 internal void Update(int id, decimal Cuota_over, decimal Cuota_under, float Dinero_over, float Dinero_under)
 {
     using (PlaceMyBetContext context = new PlaceMyBetContext())
     {
         Mercado mercado = context.Mercados
                           .Where(s => s.id == id)
                           .FirstOrDefault();
         mercado.Cuota_over   = Cuota_over;
         mercado.Cuota_under  = Cuota_under;
         mercado.Dinero_over  = Dinero_over;
         mercado.Dinero_under = Dinero_under;
         context.Update(mercado);
         context.SaveChanges();
     }
 }
Beispiel #6
0
        internal void Save(Apuestas Ap)
        {
            var     Mercadorepo = new MercadoRepository();
            Mercado merc;

            PlaceMyBetContext context = new PlaceMyBetContext();

            context.Apuestas.Add(Ap);
            merc = Mercadorepo.Retrieve(Ap.ID_MERCADO);
            if (Ap.Tipo_apuesta.ToLower() == "over")
            {
                merc.Dinero_over += Ap.Dinero_apostado;
            }
            else
            {
                merc.Dinero_under += Ap.Dinero_apostado;
            }
            context.Mercados.Update(merc);
            context.SaveChanges();
        }