public void Configurar() { EventoContext ctx = new EventoContext(); EventoService eventoService = new EventoService(ctx); convertidor = new Convertidor(eventoService); }
public async Task <IActionResult> NuevoAsync(string inputNombre, string inputInicio, string inputFinal, IFormFile inputImagen) { EventoContext context = HttpContext.RequestServices.GetService(typeof(EventoContext)) as EventoContext; if (inputImagen == null || inputImagen.Length == 0) { return(Content("file not selected")); } var path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot\\images\\", inputImagen.FileName); using (var stream = new FileStream(path, FileMode.Create)) { await inputImagen.CopyToAsync(stream); } string filePath = inputImagen.FileName; bool result = context.Add(inputNombre, inputInicio, inputFinal, filePath); if (result) { return(RedirectToAction("Nuevo", "Evento", new { result = "Success" })); } return(RedirectToAction("Nuevo", "Evento", new { result = "Failure" })); }
public IActionResult Index() { EventoContext context = HttpContext.RequestServices.GetService(typeof(EventoContext)) as EventoContext; var eventos = context.getEventos(); return(View(eventos)); }
public ActionResult EditarEvento(Lugar a) { try { using (var db = new EventoContext()) { Lugar evento = db.Lugar.Find(a.ID); evento.Nombre = a.Nombre; evento.Ubicacion = a.Ubicacion; evento.Latitud = a.Latitud; evento.Longitud = a.Longitud; evento.Categoria = a.Categoria; evento.FechaInicio = a.FechaInicio; evento.FechaFin = a.FechaFin; evento.Capacidad = a.Capacidad; evento.Descripcion = a.Descripcion; db.SaveChanges(); return(RedirectToAction("TusEventos")); } } catch (Exception ex) { ModelState.AddModelError("", "Error al encontrar al evento" + ex.Message); return(View()); } }
public IActionResult Nuevo(string result) { if (result != null) { ViewBag.result = result; } EventoContext eventos = HttpContext.RequestServices.GetService(typeof(EventoContext)) as EventoContext; ViewBag.eventos = eventos.getEventos(); return(View()); }
public IActionResult Editar(int id, string result) { if (!String.IsNullOrEmpty(result)) { ViewBag.result = result; } EventoContext context = HttpContext.RequestServices.GetService(typeof(EventoContext)) as EventoContext; var evento = context.detallesEvento(id); return(View(evento)); }
public IActionResult Editar(int id, string inputNombre, string inputInicio, string inputFinal) { EventoContext context = HttpContext.RequestServices.GetService(typeof(EventoContext)) as EventoContext; bool result = context.Edit(id, inputNombre, inputInicio, inputFinal); if (result) { return(RedirectToAction("Editar", "Evento", new { id = id, result = "Success" })); } return(RedirectToAction("Editar", "Evento", new { id = id, result = "Failure" })); }
public IActionResult Eliminar(int id) { EventoContext context = HttpContext.RequestServices.GetService(typeof(EventoContext)) as EventoContext; bool result = context.Eliminar(id); if (result) { return(RedirectToAction("Index", "Evento", new { id = id, result = "Success" })); } return(RedirectToAction("Index", "Evento", new { id = id, result = "Failure" })); }
public IActionResult Edit(int id, string result) { if (result != null) { ViewBag.result = result; } EventoContext eventos = HttpContext.RequestServices.GetService(typeof(EventoContext)) as EventoContext; NoticiaContext noticia = HttpContext.RequestServices.GetService(typeof(NoticiaContext)) as NoticiaContext; ViewBag.noticia = noticia.getNoticia(id); ViewBag.eventos = eventos.getEventos(); return(View()); }
// GET: Evento public ActionResult Evento() { try { using (var db = new EventoContext()) { return(View(db.Lugar.ToList())); } } catch (Exception ex) { ModelState.AddModelError("", "Error al igresar" + ex.Message); return(View()); } }
public IActionResult Edit(string id) { EquipoContext equipos = HttpContext.RequestServices.GetService(typeof(EquipoContext)) as EquipoContext; DisciplinaContext disciplinas = HttpContext.RequestServices.GetService(typeof(DisciplinaContext)) as DisciplinaContext; UbicacionContext ubicaciones = HttpContext.RequestServices.GetService(typeof(UbicacionContext)) as UbicacionContext; EventoContext eventos = HttpContext.RequestServices.GetService(typeof(EventoContext)) as EventoContext; PartidoContext partidos = HttpContext.RequestServices.GetService(typeof(PartidoContext)) as PartidoContext; ViewBag.equipos = equipos.GetAllEquipos(); ViewBag.disciplinas = disciplinas.getDisciplinas(); ViewBag.eventos = eventos.getEventos(); ViewBag.ubicaciones = ubicaciones.getUbicaciones(); ViewBag.partido = partidos.GetPartido(id); return(View()); }
public EventoController(EventoContext context) { _context = context; if (_context.Eventos.Count() == 0) { Int32 unixTimestamp = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds; string tag = "brasil.sudeste.sensor01"; string valor = "23"; _context.Eventos.Add(new Evento { Timestamp = unixTimestamp, Tag = tag, Valor = valor }); _context.SaveChanges(); } }
public ActionResult ProximosEventos() { try { using (var db = new EventoContext()) { List <Lugar> lista = db.Lugar.Where(a => a.FechaInicio >= DateTime.Today).ToList(); return(View(lista)); } } catch (Exception ex) { ModelState.AddModelError("", "Error al igresar" + ex.Message); return(View()); } }
public ActionResult EventosGustos(string categoria) { try { using (var db = new EventoContext()) { List <Lugar> lista = db.Lugar.Where(a => a.Categoria == categoria).ToList(); return(View(lista)); } } catch (Exception ex) { ModelState.AddModelError("", "Error al igresar" + ex.Message); return(View()); } }
public ActionResult EventosAlrededor(String Latitud, String Longitud) { try { using (var db = new EventoContext()) { List <Lugar> lista = db.Lugar.Where(a => (Math.Sqrt(Math.Pow(Double.Parse(a.Latitud) - Double.Parse(Latitud), 2) - Math.Pow(Double.Parse(a.Longitud) - Double.Parse(Longitud), 2))) < 100).ToList(); return(View(lista)); } } catch (Exception ex) { ModelState.AddModelError("", "Error al consultar" + ex.Message); return(View()); } }
public ActionResult DetallesEvento(int id) { try { using (var db = new EventoContext()) { Lugar evento = db.Lugar.Find(id); return(View(evento)); } } catch (Exception ex) { ModelState.AddModelError("", "Error al encontrar al evento" + ex.Message); return(View()); } }
public IActionResult Evento(int id) { EventoContext context = HttpContext.RequestServices.GetService(typeof(EventoContext)) as EventoContext; CompetenciaContext context1 = HttpContext.RequestServices.GetService(typeof(CompetenciaContext)) as CompetenciaContext; PartidoContext context2 = HttpContext.RequestServices.GetService(typeof(PartidoContext)) as PartidoContext; List <Partido> partidos = context2.getPartidos(); partidos = partidos.Where(x => x.evento.id == id).ToList(); List <Competencia> competencias = context1.getCompetencias(); competencias = competencias.Where(x => x.evento.id == id).ToList(); ViewBag.Evento = context.detallesEvento(id); ViewBag.Partidos = partidos; ViewBag.Competencias = competencias; return(View()); }
public ActionResult TopEventos() { try { using (var db = new EventoContext()) { List <Lugar> lista = db.Lugar.OrderByDescending(a => a.Asistentes).Take(5).ToList(); return(View(lista)); } } catch (Exception ex) { ModelState.AddModelError("", "Error al igresar" + ex.Message); return(View()); } }
public virtual void OnSetUp() { string testDatabase = $"Server=(localdb)\\mssqllocaldb;Database=app_db_{Guid.NewGuid()};Trusted_Connection=True;MultipleActiveResultSets=true"; var serviceCollection = new ServiceCollection(); var serviceProvider = serviceCollection .AddEntityFrameworkSqlServer() .BuildServiceProvider(); var builder = new DbContextOptionsBuilder <EventoContext>(); builder .EnableSensitiveDataLogging() .UseSqlServer(testDatabase) .UseInternalServiceProvider(serviceProvider); ctx = new EventoContext(builder.Options); ctx.Database.Migrate();//genera la migraci�n para la Bd mdf en memoria. }
public IActionResult Nuevo(string result) { if (!String.IsNullOrEmpty(result)) { ViewBag.result = result; } EquipoContext equipos = HttpContext.RequestServices.GetService(typeof(EquipoContext)) as EquipoContext; DisciplinaContext disciplinas = HttpContext.RequestServices.GetService(typeof(DisciplinaContext)) as DisciplinaContext; UbicacionContext ubicaciones = HttpContext.RequestServices.GetService(typeof(UbicacionContext)) as UbicacionContext; EventoContext eventos = HttpContext.RequestServices.GetService(typeof(EventoContext)) as EventoContext; ViewBag.equipos = equipos.GetAllEquipos(); ViewBag.disciplinas = disciplinas.getDisciplinas(); ViewBag.eventos = eventos.getEventos(); ViewBag.ubicaciones = ubicaciones.getUbicaciones(); return(View()); }
public ActionResult TusEventos() { try { using (var db = new EventoContext()) { String valor = User.Identity.GetUserName(); List <Lugar> lista = db.Lugar.Where(a => a.Usuario == valor).ToList(); return(View(lista)); } } catch (Exception ex) { ModelState.AddModelError("", "Error al igresar" + ex.Message); return(View()); } }
public IActionResult Nuevo(string result) { if (result != null) { ViewBag.result = result; } EventoContext eventos = HttpContext.RequestServices.GetService(typeof(EventoContext)) as EventoContext; UbicacionContext ubicaciones = HttpContext.RequestServices.GetService(typeof(UbicacionContext)) as UbicacionContext; ParticipantesContext participantes = HttpContext.RequestServices.GetService(typeof(ParticipantesContext)) as ParticipantesContext; List <Participante> lista_p = participantes.getParticipantes(); lista_p = lista_p.Where(x => x.disciplina.id.Equals(5)).ToList(); ViewBag.eventos = eventos.getEventos(); ViewBag.ubicaciones = ubicaciones.getUbicaciones(); ViewBag.participantes = lista_p; return(View()); }
static void Main(string[] args) { EventoContext ctx = new EventoContext(); EventoService es = new EventoService(ctx); IConvertidor _Convertidor = new Convertidor(es); ILector _Lector = new Lector(_Convertidor, "../../../Resources/archivo.txt"); IEscritor _Escritor = new Escritor(); IOcurrencia _Ocurrencia = new Ocurrencia(); IManejoTiemposFactory _ManejoTiemposFactory = new ManejoTiemposFactory(_Escritor, _Ocurrencia); IProcesador _Procesador = new Procesador(_ManejoTiemposFactory, _Lector); _Procesador.ProcesarEventos(); Console.ReadLine(); }
public ActionResult EliminarEvento(int id) { try { using (var db = new EventoContext()) { Lugar evento = db.Lugar.Find(id); db.Lugar.Remove(evento); db.SaveChanges(); return(RedirectToAction("TusEventos")); } } catch (Exception ex) { ModelState.AddModelError("", "Error al encontrar al evento" + ex.Message); return(View()); } }
public ActionResult CrearEvento(Lugar a) { try { using (var db = new EventoContext()) { a.Asistentes = 0; a.Usuario = User.Identity.GetUserName(); db.Lugar.Add(a); db.SaveChanges(); return(RedirectToAction("TusEventos")); } } catch (Exception ex) { ModelState.AddModelError("", "Error al agregar el evento" + ex.Message); return(View()); } }
public ActionResult Asistir(int id) { try { using (var db = new EventoContext()) { Lugar evento = db.Lugar.Find(id); if (evento.Capacidad > evento.Asistentes) { evento.Asistentes = evento.Asistentes + 1; db.SaveChanges(); } return(RedirectToAction("Evento")); } } catch (Exception ex) { ModelState.AddModelError("", "Error al encontrar al evento" + ex.Message); return(View("Evento")); } }
///TODO: ver com o Gustavo public EventoQueryRepository(EventoContext context) { _context = context; }
public EventoCommandRepository(EventoContext context) { _context = context; }
public EventoRepository() { db = new EventoContext(); }
public EventosController(EventoContext context) { _context = context; }