public ActionResult BtnEditEvento(Evento e)
 {
     try
     {
         e.IdGrupo  = int.Parse(Request.QueryString[0]);
         e.IdEvento = int.Parse(Request.QueryString[1]);
         if (e.Cep == null)
         {
             if (e.Tipo == 2)
             {
                 TempData["CepInvalido"] = "Please insert a cep for creating a lan event";
                 return(RedirectToAction("EditEvento", "Evento", new { GrupoId = e.IdGrupo, EventoId = e.IdEvento }));
             }
         }
         else
         {
             if (Validacoes.VerificarValidadeDoCep(e.Cep) == false)
             {
                 TempData["CepInvalido"] = "Invalid Zip-Code!";
                 return(RedirectToAction("EditEvento", "Evento", new { GrupoId = e.IdGrupo, EventoId = e.IdEvento }));
             }
         }
         using (EventoModel model = new EventoModel())
         {
             model.EditInfoEvento(e);
         }
         return(RedirectToAction("Index", "Evento", new { GrupoId = e.IdGrupo, EventoId = e.IdEvento }));
     }
     catch (Exception ex)
     {
         Console.WriteLine("{0} Exception caught", ex);
         return(RedirectToAction("Erro404", "Error"));
     }
 }
Beispiel #2
0
        public IHttpActionResult Criar(EventoModel model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(Content(HttpStatusCode.Forbidden, ErrosModel()));
                }

                var _obj = new Evento()
                {
                    Data       = model.Data,
                    Descricao  = model.Descricao,
                    Endereco   = model.Endereco,
                    TipoEvento = model.TipoEvento,
                    Valor      = model.Valor,
                    Cidade     = model.Cidade
                };

                this.service.Add(_obj);

                return(Ok("Evento Registrado!"));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
        public ActionResult Members()
        {
            try
            {
                int idgrupo  = int.Parse(Request.QueryString[0]);
                int idevento = int.Parse(Request.QueryString[1]);

                Evento e = new Evento();
                using (EventoModel model = new EventoModel())
                {
                    e = model.ReadEvento(idevento, idgrupo);                                            //Pega as informações do evento
                    ViewBag.ReadEvento = e;
                    DateTime date = Convert.ToDateTime(e.Data);
                    ViewBag.DataFormatada = date.ToString(@"dd-MM-yyyy");                               //Converte a data pro formato de dia/mes/ano
                }
                using (EventoModel model = new EventoModel())
                {
                    ViewBag.ViewConfUserEventoAll = model.ViewConfUserEventoAll(idgrupo, idevento);     //Mostra os usuarios com presença confirmada
                }
                using (EventoModel model = new EventoModel())
                {
                    ViewBag.QuantUserPartEvento = model.QuantUserPartEvento(idgrupo, idevento);         //Retorna o count de usuarios que vão ao evento
                }
                using (GrupoModel model = new GrupoModel())
                {
                    ViewBag.InfoGrupo = model.InfoGrupo(idgrupo);                       //Pega as informações do grupo pra mostrar
                }
                return(View(e));
            }
            catch (Exception ex)
            {
                Console.WriteLine("{0} Exception caught", ex);
                return(RedirectToAction("Erro404", "Error"));
            }
        }
        public void Handle(RegistrarEventoCommand message)
        {
            var evento = new EventoModel(
                message.Nome,
                message.DataInicio,
                message.DataFim,
                message.Gratuito,
                message.Valor,
                message.Online,
                message.NomeEmpresa);

            if (!evento.EhValido())
            {
                NotificarValidacoesErro(evento.ValidationResult);
                return;
            }
            //TODO:
            //Validações de negócio!
            //Persistencia

            _eventoRepository.Add(evento);

            if (Commit())
            {
                Console.WriteLine("Evento Registrado com sucesso!");
                _bus.RaiseEvent(new EventoRegistradoEvent(evento.Id, evento.Nome,
                                                          evento.DataInicio,
                                                          evento.DataFim,
                                                          evento.Gratuito,
                                                          evento.Valor,
                                                          evento.Online,
                                                          evento.NomeEmpresa));
            }
        }
Beispiel #5
0
        public async Task <IActionResult> Post(EventoModel model)
        {
            //ToDo: sem a anotação no inicio da api apicontroller tenho que avisar para o metodo que o
            //envio dos dados é via corpo com o frombody e preciso validar o model
            //if (!ModelState.IsValid)
            //	return this.StatusCode(StatusCodes.Status400BadRequest, ModelState);

            try
            {
                var evento = _mapper.Map <Evento>(model);

                _repo.Add(evento);

                if (await _repo.SaveChangesAsync())
                {
                    return(Created($"/api/evento/{model.Id}", _mapper.Map <EventoModel>(evento)));
                }
            }
            catch (Exception ex)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, $"Banco Dados Falhou {ex.Message}"));
            }

            return(BadRequest());
        }
Beispiel #6
0
        public ActionResult SeleccionarEvento(int IdEvento)
        {
            try
            {
                EntidadesCompartidas.Evento evento = new Evento();

                evento = Logica.FabricaLogica.getLogicaEvento().BuscarEvento(IdEvento);

                EventoModel model = new EventoModel();

                model.IdEvento = evento.IdEvento;
                model.ClasificacionEvento.NombreCategoria = evento.CategoriaEvento.NombreCategoria;
                model.ClasificacionEvento.Descripcion     = evento.CategoriaEvento.Descripcion;
                model.Descripcion                     = evento.Descripcion;
                model.FechaInicio                     = evento.FechaInicio;
                model.FechaFin                        = evento.FechaFin;
                model.OrganizadorEvento.CI            = evento.UnOrganizador.CI;
                model.OrganizadorEvento.Contraseña    = evento.UnOrganizador.Contraseña;
                model.OrganizadorEvento.Email         = evento.UnOrganizador.Email;
                model.OrganizadorEvento.Nombre        = evento.UnOrganizador.Nombre;
                model.OrganizadorEvento.NombreUsuario = evento.UnOrganizador.NombreUsuario;

                Session["EventoSeleccionado"] = model;

                return(View("", model));
            }
            catch
            {
                return(View());
            }
        }
Beispiel #7
0
 public ActionResult Create(Evento e)
 {
     try
     {
         if (ModelState.IsValid)
         {
             using (EventoModel model = new EventoModel())
             {
                 e.Organizador.Id_usuario = (Session["usuario"] as Usuario).Id_usuario;
                 model.Create(e);
             }
             TempData["sucessoCriar"] = "Success";
             return(RedirectToAction("UserEvents", "Event"));
         }
         else
         {
             TempData["erroCriar"] = "Error";
             return(RedirectToAction("UserEvents", "Event"));
         }
     }
     catch
     {
         TempData["erroCriar"] = "Erro";
         return(RedirectToAction("UserEvents", "Event"));
     }
 }
        public NovoEventoPage()
        {
            InitializeComponent();

            Evento = new EventoModel();

            BindingContext = this;
        }
Beispiel #9
0
        public EventoDetailPage()
        {
            InitializeComponent();

            var item = new EventoModel();

            viewModel      = new InscricaoViewModel(item);
            BindingContext = viewModel;
        }
Beispiel #10
0
        public ActionResult FeedEvents()
        {
            using (EventoModel model = new EventoModel())
            {
                ViewBag.Feed = model.FeedEvents((Session["usuario"] as Usuario).Id_usuario);
            }

            return(View());
        }
Beispiel #11
0
 public ActionResult RemoveUserEvent(int IdEvent, int IdUser)
 {
     using (EventoModel model = new EventoModel())
     {
         model.ChangeStatusSubscribe(IdEvent, IdUser, 3);
     }
     TempData["successManager"] = "User Removed";
     return(RedirectToAction("Manager", "Event", new { EventoID = IdEvent }));
 }
Beispiel #12
0
        public async Task <IActionResult> Put(int EventoId, EventoModel model)
        {
            try
            {
                //if (!ModelState.IsValid) return BadRequest();

                var evento = await _repo.GetEventoAsyncById(EventoId, false);

                if (evento == null)
                {
                    return(NotFound());
                }

                var idLotes        = new List <int>();
                var idRedesSociais = new List <int>();

                model.Lotes.ForEach(item => idLotes.Add(item.Id));
                model.RedesSociais.ForEach(item => idRedesSociais.Add(item.Id));

                var lotes = evento.Lotes.Where(
                    lote => !idLotes.Contains(lote.Id)
                    ).ToArray();

                var redesSociais = evento.RedesSociais.Where(
                    rede => !idLotes.Contains(rede.Id)
                    ).ToArray();

                if (lotes.Length > 0)
                {
                    _repo.DeleteRange(lotes);
                }
                if (redesSociais.Length > 0)
                {
                    _repo.DeleteRange(redesSociais);
                }

                _mapper.Map(model, evento);

                //ToDo: retirar depois que arrumar o mapeamento
                //MapModelToEntity(model, evento);

                _repo.Update(evento);

                if (await _repo.SaveChangesAsync())
                {
                    //return Created($"/api/evento/{model.Id}", model);
                    return(Created($"/api/evento/{model.Id}", _mapper.Map <EventoModel>(evento)));
                }
            }
            catch (System.Exception ex)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError, "Banco Dados Falhou " + ex.Message));
            }

            return(BadRequest());
        }
        private bool EventoValido(EventoModel evento)
        {
            if (evento.EhValido())
            {
                return(true);
            }

            NotificarValidacoesErro(evento.ValidationResult);
            return(false);
        }
Beispiel #14
0
 private void MapModelToEntity(EventoModel model, Evento evento)
 {
     evento.Nome       = model.Nome;
     evento.Local      = model.Local;
     evento.ImagemURL  = model.ImagemURL;
     evento.DataEvento = Convert.ToDateTime(model.DataEvento);
     evento.Email      = model.Email;
     evento.Telefone   = model.Telefone;
     evento.QtdPessoas = model.QtdPessoas;
 }
Beispiel #15
0
        public ActionResult EditImageEvent(FormCollection form, int id)
        {
            int idEvento = id;
            HttpPostedFileBase arquivo = Request.Files[0];

            if (ModelState.IsValid)
            {
                string Foto_Perfil = null;
                using (System.Drawing.Image pic = System.Drawing.Image.FromStream(arquivo.InputStream))
                {
                    /*if (pic.Height != 256 && pic.Width != 256)
                     * {
                     *
                     *  return RedirectToAction("Edit");
                     * }
                     * else*/
                    if (arquivo.ContentType != "image/png" && arquivo.ContentType != "image/jpeg" && arquivo.ContentType != "image/jpg")
                    {
                        TempData["errorManager"] = "Check the photo format";
                        return(RedirectToAction("Manager", "Event", new { EventoID = idEvento }));
                    }
                    else if (arquivo.ContentLength > 2097152)
                    {
                        TempData["errorManager"] = "Very large picture";
                        return(RedirectToAction("Manager", "Event", new { EventoID = idEvento }));
                    }
                }

                if (Request.Files.Count > 0)
                {
                    if (arquivo.ContentLength > 0)
                    {
                        DateTime today = DateTime.Now;
                        string   img   = "/Pictures/Event/" + idEvento.ToString() + today.ToString("yyyyMMddhhmmss") + System.IO.Path.GetExtension(arquivo.FileName);
                        string   path  = HostingEnvironment.ApplicationPhysicalPath;

                        string caminho = path + "\\Pictures\\Event\\" + idEvento.ToString() + today.ToString("yyyyMMddhhmmss") + System.IO.Path.GetExtension(arquivo.FileName);
                        arquivo.SaveAs(caminho);
                        Foto_Perfil = img;
                    }
                }
                using (EventoModel model = new EventoModel())
                {
                    model.UpdateImage(idEvento, Foto_Perfil);
                }

                TempData["successManager"] = "Picutere Changed";
                return(RedirectToAction("Manager", "Event", new { EventoID = idEvento }));
            }
            else
            {
                TempData["errorManager"] = "Erro Changed Picutere";
                return(RedirectToAction("Manager", "Event", new { EventoID = idEvento }));
            }
        }
Beispiel #16
0
        private void MarcarEventos()
        {
            List <EventoEntity> lista = EventoModel.Listar();

            foreach (EventoEntity item in lista)
            {
                myMonthCalendar.AddBoldedDate(item.Data);
            }

            myMonthCalendar.UpdateBoldedDates();
        }
Beispiel #17
0
        public static EventoModel MapEventoToModel(evento entity)
        {
            EventoModel model = new EventoModel();

            model.EventoId        = entity.idEvento;
            model.PostiFree       = entity.postiDisponibili;
            model.EventDate       = entity.dataEvento;
            model.AbbonamentiFree = entity.abbonamentiDisponibili;
            model.TipologiaId     = entity.abbonamentiDisponibili;
            return(model);
        }
Beispiel #18
0
        public ActionResult Unsubscribe(int idEvento)
        {
            int idUser = (Session["usuario"] as Usuario).Id_usuario;

            using (EventoModel model = new EventoModel())
            {
                model.DesinscreverEvento(idEvento, idUser);
            }

            return(RedirectToAction("Home", "Event", new { EventoID = idEvento }));
        }
Beispiel #19
0
        public static evento MapEventToEntity(EventoModel model)
        {
            evento entity = new evento();

            entity.idEvento               = model.EventoId;
            entity.postiDisponibili       = model.PostiFree;
            entity.dataEvento             = model.EventDate;
            entity.abbonamentiDisponibili = model.AbbonamentiFree;
            entity.abbonamentiDisponibili = model.TipologiaId;

            return(entity);
        }
Beispiel #20
0
        public void Delete(Expression <Func <TimeModel, bool> > filter)
        {
            Server   s     = Server.Instance();
            Database local = new Database("local", s);
            Collection <TimeModel>   times   = new Collection <TimeModel>("times", local);
            Collection <EventoModel> eventos = new Collection <EventoModel>("eventos", local);
            TimeModel   dados  = (TimeModel)filter.Compile().Target;
            EventoModel evento = eventos.Documents.Find(x => x.Id == dados.EventoId);

            evento.Times?.Remove(dados.Id);
            eventos.UpdateDocument(x => x.Id == dados.EventoId, evento);
            times.DeleteDocument(x => x.Id == dados.Id);
        }
Beispiel #21
0
        public void Delete(TimeModel item)
        {
            Server   s     = Server.Instance();
            Database local = new Database("local", s);
            Collection <TimeModel>   times   = new Collection <TimeModel>("times", local);
            Collection <EventoModel> eventos = new Collection <EventoModel>("eventos", local);
            TimeModel   dados  = item;
            EventoModel evento = eventos.Documents.Find(x => x.Id == dados.EventoId);

            evento.Times?.Remove(dados.Id);
            eventos.UpdateDocument(x => x.Id == dados.EventoId, evento);
            times.DeleteDocument(x => x.Id == dados.Id);
        }
Beispiel #22
0
        public EntidadesCompartidas.Evento ModelEvento(EventoModel e)
        {
            EntidadesCompartidas.Evento _evento = new EntidadesCompartidas.Evento();

            _evento.NombreEvento    = e.NombreEvento;
            _evento.Descripcion     = e.Descripcion;
            _evento.FechaInicio     = e.FechaInicio;
            _evento.FechaFin        = e.FechaFin;
            _evento.CategoriaEvento = e.ClasificacionEvento;
            _evento.AreaEvento      = new EntidadesCompartidas.Area();//e.UnLugar;

            return(_evento);
        }
Beispiel #23
0
        private void Calendar_Double_Click(object sender, EventArgs e)
        {
            DateTime dataSelecionada = myMonthCalendar.SelectionStart;

            EventoEntity entity;

            //verifica se já tem evento pra data
            if (myMonthCalendar.BoldedDates.Contains(dataSelecionada))
            {
                entity = EventoModel.Buscar(dataSelecionada);
            }
            else
            {
                entity = new EventoEntity()
                {
                    Data = dataSelecionada
                };
            }

            //abre a tela pra cadastro ou edição

            CadastroEventoForm form = new CadastroEventoForm(entity);

            form.ShowDialog();

            StatusEnum status = form.Status;

            switch (status)
            {
            case StatusEnum.INCLUIDO:
            {
                myMonthCalendar.AddBoldedDate(dataSelecionada);
                myMonthCalendar.UpdateBoldedDates();

                break;
            }

            case StatusEnum.REMOVIDO:
            {
                myMonthCalendar.RemoveBoldedDate(dataSelecionada);
                myMonthCalendar.UpdateBoldedDates();
                break;
            }

            default:
            {
                break;
            }
            }
        }
Beispiel #24
0
 public ActionResult Index(Mensagem e)
 {
     try
     {
         int iduser = ((Usuario)Session["usuario"]).IdPessoa;
         ViewBag.IdUsuario = iduser;
         if (ModelState.IsValid)
         {
             int idgrupo = int.Parse(Request.QueryString["GrupoId"]);                        //Converte o Id da URL para poder ser usado
             using (GrupoModel model = new GrupoModel())
             {
                 ViewBag.ReadPartGrupo = model.ReadPartGrupo(idgrupo);               //Seleciona 6 primeiros usuarios e mostra na lista do grupo
             }
             using (GrupoModel model = new GrupoModel())
             {
                 ViewBag.InfoGrupo = model.InfoGrupo(idgrupo);                       //Pega as informações do grupo pra mostrar
             }
             using (GrupoModel model = new GrupoModel())
             {
                 ViewBag.QuantUserGrupos = model.QuantUserGrupos(idgrupo);           //Mostra o count de usuarios na div de grupos
             }
             using (GrupoModel model = new GrupoModel())
             {
                 ViewBag.StatusUserGrupo = model.StatusUserGrupo(iduser, idgrupo);   //Retorna o status pra mostra o botão pro usuario
             }
             using (MensagemModel model = new MensagemModel())
             {
                 model.PostMensagem(e, iduser, idgrupo);                          //Model pra fazer post da mensagem
             }
             using (MensagemModel model = new MensagemModel())
             {
                 ViewBag.ReadMensagem = model.ReadMensagem(idgrupo, 10);                 //Ler as mensagens já postadas no grupo
             }
             using (MensagemModel model = new MensagemModel())
             {
                 ViewBag.QuantMsgGrupo = model.QuantMsgGrupo(idgrupo);
             }
             using (EventoModel model = new EventoModel())
             {
                 ViewBag.ViewEventosIndex = model.ViewEventosIndex(idgrupo);                   //Mostra os eventos cadastrados no grupo
             }
         }
         return(View());
     }
     catch (Exception ex)
     {
         Console.WriteLine("{0} Exception caught", ex);
         return(RedirectToAction("Erro404", "Error"));
     }
 }
Beispiel #25
0
        private void CadastrarLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            bool erro = false;

            try
            {
                String[] horaEvento = InicioMaskedTextBox.Text.Split(':');
                int      horas      = int.Parse(horaEvento[0]);
                int      minutos    = int.Parse(horaEvento[1]);
                int      segundos   = 0;
                entity.Inicio = new TimeSpan(horas, minutos, segundos);
            }
            catch
            {
                MessageBox.Show("Erro na Hora de inicio");
                InicioMaskedTextBox.Focus();
                erro = true;
            }

            if (!erro)
            {
                try
                {
                    String[] horaEvento = FimMaskedTextBox.Text.Split(':');
                    int      horas      = int.Parse(horaEvento[0]);
                    int      minutos    = int.Parse(horaEvento[1]);
                    int      segundos   = 0;
                    entity.Fim = new TimeSpan(horas, minutos, segundos);

                    entity.Descricao = DescricaoTextBox.Text;

                    if (EventoModel.Salvar(entity))
                    {
                        Status = StatusEnum.INCLUIDO;

                        this.Dispose();
                    }
                    else
                    {
                        MessageBox.Show("Erro ao salvar evento");
                    }
                }
                catch
                {
                    MessageBox.Show("Erro na Hora final");
                    FimMaskedTextBox.Focus();
                }
            }
        }
        public IActionResult Post([FromBody] EventoModel eventoModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Evento evento = new Evento(eventoModel.Nome, eventoModel.DataInicio, eventoModel.DataFim, eventoModel.SalaId);

            this._contexto.Add(evento);

            this._contexto.SaveChanges();

            return(Created("Evento inserido com sucesso.", evento));
        }
Beispiel #27
0
 private void ExcluirLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     if (MessageBox.Show("Deseja Excluir este evento?", "Exclusao!!!", MessageBoxButtons.YesNo) == DialogResult.Yes)
     {
         if (EventoModel.Remover(entity))
         {
             Status = StatusEnum.REMOVIDO;
             this.Dispose();
         }
         else
         {
             MessageBox.Show("Erro ao remover evento");
         }
     }
 }
Beispiel #28
0
        public async Task <IActionResult> Add([FromBody] EventoModel data)
        {
            var evento = new Evento
            {
                Observacao       = data.Nome,
                PermiteSubEvento = data.PermiteSubEvento,
                Horario          = data.Horario,
                Localizacao      = data.Localizacao,
            };

            evento.Participantes = GetParticipantes(evento, data.Participantes);
            evento.Agrupamentos  = GetAgrupamentos(evento, data.Agrupamentos);
            await Service.Add(data.CompeticaoId, evento);

            return(Ok());
        }
Beispiel #29
0
        public ActionResult ControlEventos()
        {
            MVCFinal.Models.EventoModel Evento = new EventoModel();

            try
            {
                List <EntidadesCompartidas.Evento> lista = Logica.FabricaLogica.getLogicaEvento().ListarEventosOrdenFecha();

                Evento.milista = lista;
                return(View(Evento));
            }
            catch
            {
                return(View());
            }
        }
Beispiel #30
0
 public ActionResult Create(Evento e)
 {
     try
     {
         int idgrupo = int.Parse(Request.QueryString[0]);                    //Converte o primeiro parametro da URL para poder ser usado
         using (GrupoModel model = new GrupoModel())
         {
             ViewBag.InfoGrupo = model.InfoGrupo(idgrupo);                   //Pega as informações do grupo pra mostrar
         }
         if (ModelState.IsValid)
         {
             using (EventoModel model2 = new EventoModel())
             {
                 DateTime date       = DateTime.Now;
                 DateTime dataevento = Convert.ToDateTime(e.Data);
                 if (dataevento < date)
                 {
                     TempData["DataInvalida"] = "Your event date is older than the current date, for creating an event please use a newer date.";
                     return(View(e));
                 }
                 if (e.Cep == null)
                 {
                     if (e.Tipo == 2)
                     {
                         TempData["CepInvalido"] = "Please insert a cep for creating a lan event";
                         return(RedirectToAction("Create", "Evento", new { GrupoId = idgrupo }));
                     }
                 }
                 else
                 {
                     if (Validacoes.VerificarValidadeDoCep(e.Cep) == false)
                     {
                         TempData["CepInvalido"] = "Invalid Zip-Code!";
                         return(RedirectToAction("Create", "Evento", new { GrupoId = idgrupo }));
                     }
                 }
                 model2.Create(e, idgrupo);                                   //Cria o evento
             }
         }
         return(RedirectToAction("Index", "Grupo", new { GrupoId = idgrupo }));
     }
     catch (Exception f)
     {
         Console.WriteLine("{0} Exception caught", f);
         return(RedirectToAction("Erro404", "Error"));
     }
 }