public ActionResult Index(ReservationVM NewReservation) { using (var db = new Y2kContext()) { db.Reservacion.Add(NewReservation.Reservation); db.SaveChanges(); return(RedirectToAction("Resultado", new { Id = NewReservation.Reservation.Id })); } }
public ActionResult Resultado(int Id) { Reservation reservation = new Reservation(); using (var db = new Y2kContext()) { reservation = db.Reservacion.Include("City").FirstOrDefault(s => s.Id == Id); } return(View(reservation)); }
/// <summary> /// Carga las ciudades a la BD /// </summary> public static void GetCity() { using (Y2kContext context = new Y2kContext()) { if (!context.City.Any()) { //string content = Task.Run(GetDate).Result; //List<City> cities = JsonConvert.DeserializeObject<List<City>>(content); //context.City.AddRange(cities); //context.SaveChanges(); } } }
/// <summary> /// Guarda el clima de una ciudad en especifico /// </summary> /// <param name="id"></param> public static Models.Weather GetWeather(int id) { _id = id; Models.Weather weather = new Models.Weather(); string content = Task.Run(GetWeather).Result; WeatherAPI weathers = JsonConvert.DeserializeObject <WeatherAPI>(content); weather.IdExternal = weathers.weather[0].id; weather.Main = weathers.weather[0].main; weather.Description = weathers.weather[0].description; weather.Icon = weathers.weather[0].icon; weather.cod = weathers.cod; using (Y2kContext context = new Y2kContext()) { context.Weather.Add(weather); context.SaveChanges(); } return(weather); }
/// <summary> /// Carga las ciudades a la BD /// </summary> public static void GetCity() { using (Y2kContext context = new Y2kContext()) { if (!context.City.Any()) { string content = Task.Run(GetDate).Result; List <Models.City> cities = JsonConvert.DeserializeObject <List <Models.City> >(content); foreach (var c in cities) { Models.City city = new Models.City(); city.IdExternal = c.Id; city.Name = c.Name; city.Country = c.Country; context.City.Add(city); } context.SaveChanges(); } } }
public WeatherController() {//Inicisliza el contexto context = new Y2kContext(); }
public CityController() {//Inicisliza el contexto context = new Y2kContext(); }