/*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(); }
/*** 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(); } }
public MercadosDTO ToDTO(Mercado m) { return(new MercadosDTO(m.tipo_mercado, m.Cuota_over, m.Cuota_under)); }