コード例 #1
0
        public void Configurar()
        {
            EventoContext ctx           = new EventoContext();
            EventoService eventoService = new EventoService(ctx);

            convertidor = new Convertidor(eventoService);
        }
コード例 #2
0
        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" }));
        }
コード例 #3
0
        public IActionResult Index()
        {
            EventoContext context = HttpContext.RequestServices.GetService(typeof(EventoContext)) as EventoContext;
            var           eventos = context.getEventos();

            return(View(eventos));
        }
コード例 #4
0
 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());
     }
 }
コード例 #5
0
        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());
        }
コード例 #6
0
        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));
        }
コード例 #7
0
        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" }));
        }
コード例 #8
0
        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" }));
        }
コード例 #9
0
        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());
        }
コード例 #10
0
 // 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());
     }
 }
コード例 #11
0
        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());
        }
コード例 #12
0
        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();
            }
        }
コード例 #13
0
 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());
     }
 }
コード例 #14
0
 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());
     }
 }
コード例 #15
0
 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());
     }
 }
コード例 #16
0
 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());
     }
 }
コード例 #17
0
        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());
        }
コード例 #18
0
 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());
     }
 }
コード例 #19
0
        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.
        }
コード例 #20
0
        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());
        }
コード例 #21
0
 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());
     }
 }
コード例 #22
0
        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());
        }
コード例 #23
0
        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();
        }
コード例 #24
0
 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());
     }
 }
コード例 #25
0
 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());
     }
 }
コード例 #26
0
        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"));
            }
        }
コード例 #27
0
 ///TODO: ver com o Gustavo
 public EventoQueryRepository(EventoContext context)
 {
     _context = context;
 }
コード例 #28
0
 public EventoCommandRepository(EventoContext context)
 {
     _context = context;
 }
コード例 #29
0
 public EventoRepository()
 {
     db = new EventoContext();
 }
コード例 #30
0
 public EventosController(EventoContext context)
 {
     _context = context;
 }