Beispiel #1
0
        public Boolean InserirNovoParticipanteHobbieComRetorno(MA_PARTICIPANTE_HOBBIE hobbieparticipante)
        {
            if (!VerificarSeExisteRelacaoDeParticipanteHobbie(hobbieparticipante))
            {
                try
                {
                    this.Contexto.MA_PARTICIPANTE_HOBBIE.Add(hobbieparticipante);
                    this.Contexto.SaveChanges();

                    return(true);
                }
                catch (Exception)
                {
                    return(false);
                }
            }
            else
            {
                MA_PARTICIPANTE_HOBBIE participantehobbieconferencia = ObterParticipanteHobbiePorItemEParticipante(hobbieparticipante);

                if (participantehobbieconferencia.cod_status != hobbieparticipante.cod_status)
                {
                    return(AtualizarAprendizadoDeHobbieComRetorno(hobbieparticipante));
                }
                else
                {
                    return(false);
                }
            }
        }
        public ActionResult Update(List <ParticipanteHobbie> listaparticipantehobbie)
        {
            JsonResult jsonResult;

            //Verifica se o registro é inválido e se sim, retorna com erro.
            if (listaparticipantehobbie == null)
            {
                jsonResult = Json(new
                {
                    success = false
                }, JsonRequestBehavior.AllowGet);

                jsonResult.MaxJsonLength = int.MaxValue;
                return(jsonResult);
            }
            foreach (ParticipanteHobbie pe in listaparticipantehobbie)
            {
                MA_PARTICIPANTE_HOBBIE participantehobbie = new MA_PARTICIPANTE_HOBBIE();
                participantehobbie.cod_p_hobbie     = pe.cod_p_hobbie;
                participantehobbie.cod_participante = pe.cod_participante;
                participantehobbie.cod_item         = pe.cod_item;
                participantehobbie.cod_s_relacao    = pe.cod_s_relacao;

                this.GestorDeHobbieDeParticipante.InserirNovoParticipanteHobbie(participantehobbie);
            }

            jsonResult = Json(new
            {
                success = true
            }, JsonRequestBehavior.AllowGet);

            jsonResult.MaxJsonLength = int.MaxValue;
            return(jsonResult);
        }
Beispiel #3
0
        //Exclui determinado participante do banco de dados
        protected void Delete(object sender, DirectEventArgs e)
        {
            MA_PARTICIPANTE_HOBBIE hobbieparticipante = this.GestorDeHobbieDeParticipante.ObterHobbieDoParticipantePorId(Int32.Parse(cod_p_hobbieId.Text));

            this.GestorDeHobbieDeParticipante.RemoverHobbieDoParticipante(hobbieparticipante);
            LimpaForm();
        }
Beispiel #4
0
        public void AtualizarAprendizadoDeHobbieSemConferencia(MA_PARTICIPANTE_HOBBIE hobbieparticipante)
        {
            MA_PARTICIPANTE_HOBBIE participantehobbie = new MA_PARTICIPANTE_HOBBIE();

            this.Contexto.Entry(hobbieparticipante).State = EntityState.Modified;
            this.Contexto.SaveChanges();
        }
Beispiel #5
0
 public Boolean VerificarSeExisteRelacaoDeParticipanteAprender(MA_PARTICIPANTE_HOBBIE participantehobbie)
 {
     if (ObterParticipanteHobbiePorItemEParticipante(participantehobbie) != null)
     {
         return(true);
     }
     return(false);
 }
Beispiel #6
0
        public ActionResult Add(List <ParticipanteHobbie> listaparticipantehobbie)
        {
            JsonResult jsonResult;

            //Verifica se o registro é inválido e se sim, retorna com erro.
            if (listaparticipantehobbie == null)
            {
                jsonResult = Json(new
                {
                    codigo = -1
                }, JsonRequestBehavior.AllowGet);

                jsonResult.MaxJsonLength = int.MaxValue;
                return(jsonResult);
            }
            else
            {
                MA_PARTICIPANTE_HOBBIE participantehobbie = new MA_PARTICIPANTE_HOBBIE();

                participantehobbie.cod_participante = listaparticipantehobbie[0].CodParticipante;
                participantehobbie.cod_item         = listaparticipantehobbie[0].CodItem;

                //Informa que a relação estará ativa
                participantehobbie.cod_status = 1;

                try
                {
                    Boolean resultado = GestorDeHobbieDeParticipante.InserirNovoParticipanteHobbieComRetorno(participantehobbie);

                    if (resultado)
                    {
                        jsonResult = Json(new
                        {
                            codigo = participantehobbie.cod_p_hobbie
                        }, JsonRequestBehavior.AllowGet);
                    }
                    else
                    {
                        jsonResult = Json(new
                        {
                            codigo = -1
                        }, JsonRequestBehavior.AllowGet);
                    }
                }
                catch (Exception e)
                {
                    jsonResult = Json(new
                    {
                        erro   = e.InnerException.ToString(),
                        codigo = -1
                    }, JsonRequestBehavior.AllowGet);
                }
            }

            jsonResult.MaxJsonLength = int.MaxValue;
            return(jsonResult);
        }
Beispiel #7
0
        public void AtualizarAprendizadoDeHobbieSemConferencia(MA_PARTICIPANTE_HOBBIE hobbieparticipante)
        {
            MIMACHEREntities contexto = new MIMACHEREntities();

            try
            {
                contexto.Entry(hobbieparticipante).State = EntityState.Modified;
                contexto.SaveChanges();
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Beispiel #8
0
        public void AtualizarHobbieDoParticipante(MA_PARTICIPANTE_HOBBIE hobbieparticipante)
        {
            if (!VerificarSeExisteRelacaoDeParticipanteHobbie(hobbieparticipante))
            {
                AtualizarAprendizadoDeHobbieSemConferencia(hobbieparticipante);
            }
            else
            {
                MA_PARTICIPANTE_HOBBIE participantehobbieconferencia = ObterParticipanteHobbiePorItemEParticipante(hobbieparticipante);

                if (participantehobbieconferencia.cod_status != hobbieparticipante.cod_status)
                {
                    AtualizarAprendizadoDeHobbieSemConferencia(hobbieparticipante);
                }
            }
        }
Beispiel #9
0
        public Boolean AtualizarAprendizadoDeHobbieComRetorno(MA_PARTICIPANTE_HOBBIE hobbieparticipante)
        {
            MA_PARTICIPANTE_HOBBIE participantehobbie = new MA_PARTICIPANTE_HOBBIE();

            try
            {
                this.Contexto.Entry(hobbieparticipante).State = EntityState.Modified;
                this.Contexto.SaveChanges();

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Beispiel #10
0
        public void InserirNovoParticipanteHobbie(MA_PARTICIPANTE_HOBBIE hobbieparticipante)
        {
            if (!VerificarSeExisteRelacaoDeParticipanteHobbie(hobbieparticipante))
            {
                this.Contexto.MA_PARTICIPANTE_HOBBIE.Add(hobbieparticipante);
                this.Contexto.SaveChanges();
            }
            else
            {
                MA_PARTICIPANTE_HOBBIE participantehobbieconferencia = ObterParticipanteHobbiePorItemEParticipante(hobbieparticipante);

                if (participantehobbieconferencia.cod_status != hobbieparticipante.cod_status)
                {
                    AtualizarAprendizadoDeHobbieSemConferencia(hobbieparticipante);
                }
            }
        }
Beispiel #11
0
        //Cadastro do participante no banco
        protected void Save(object sender, DirectEventArgs e)
        {
            MA_PARTICIPANTE_HOBBIE hobbieparticipante = new MA_PARTICIPANTE_HOBBIE();

            hobbieparticipante.cod_participante = Int32.Parse(cod_participanteId.SelectedItem.Value);
            hobbieparticipante.cod_item         = Int32.Parse(cod_itemId.SelectedItem.Value);
            hobbieparticipante.cod_status       = Int32.Parse(cod_statusId.SelectedItem.Value);

            //Caso o form não possui código, será inserido um novo hobbie de participante
            if (cod_p_hobbieId.Text == "")
            {
                this.GestorDeHobbieDeParticipante.InserirNovoParticipanteHobbie(hobbieparticipante);
                ParticipanteHobbieWindowId.Close();
                LimpaForm();
            }
            //Caso contrário, o form será atualizado
            else
            {
                hobbieparticipante.cod_p_hobbie = Int32.Parse(cod_p_hobbieId.Text);
                this.GestorDeHobbieDeParticipante.AtualizarHobbieDoParticipante(hobbieparticipante);
                ParticipanteHobbieWindowId.Close();
                LimpaForm();
            }
        }
Beispiel #12
0
        public Boolean AtualizarHobbieDoParticipanteComRetorno(MA_PARTICIPANTE_HOBBIE hobbieparticipante)
        {
            if (!VerificarSeExisteRelacaoDeParticipanteHobbie(hobbieparticipante))
            {
                AtualizarAprendizadoDeHobbieSemConferencia(hobbieparticipante);

                return(true);
            }
            else
            {
                MA_PARTICIPANTE_HOBBIE participantehobbieconferencia = ObterParticipanteHobbiePorItemEParticipante(hobbieparticipante.cod_item, hobbieparticipante.cod_participante);

                if (participantehobbieconferencia.cod_status != hobbieparticipante.cod_status)
                {
                    AtualizarAprendizadoDeHobbieSemConferencia(hobbieparticipante);

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
Beispiel #13
0
 public void RemoverHobbieDoParticipante(MA_PARTICIPANTE_HOBBIE hobbiedoparticipante)
 {
     this.Contexto.MA_PARTICIPANTE_HOBBIE.Remove(hobbiedoparticipante);
     this.Contexto.SaveChanges();
 }
Beispiel #14
0
 public List <MA_PARTICIPANTE_HOBBIE> ObterTodosOsHobbiesDeParticipantePorPorItemPaginadosPorVinteRegistros(MA_PARTICIPANTE_HOBBIE participantehobbie)
 {
     return(this.RepositorioDeParcipanteHobbie.ObterTodosOsHobbiesDeParticipantePorPorItemPaginadosPorVinteRegistros(participantehobbie));
 }
Beispiel #15
0
 public void InserirNovoParticipanteHobbie(MA_PARTICIPANTE_HOBBIE hobbieparticipante)
 {
     this.RepositorioDeParcipanteHobbie.InserirNovoParticipanteHobbie(hobbieparticipante);
 }
Beispiel #16
0
 public Boolean InserirNovoParticipanteHobbieComRetorno(MA_PARTICIPANTE_HOBBIE hobbieparticipante)
 {
     return(this.RepositorioDeParcipanteHobbie.InserirNovoParticipanteHobbieComRetorno(hobbieparticipante));
 }
Beispiel #17
0
 public List <MA_PARTICIPANTE_HOBBIE> ObterTodosOsHobbiesDeParticipantePorPorItemPaginadosPorVinteRegistros(MA_PARTICIPANTE_HOBBIE participantehobbie)
 {
     return(this.Contexto.MA_PARTICIPANTE_HOBBIE.Where(l => l.cod_item == participantehobbie.cod_item && l.cod_status == 1).OrderBy(l => l.cod_participante).Skip(participantehobbie.cod_p_hobbie).Take(20).ToList());
 }
Beispiel #18
0
 public MA_PARTICIPANTE_HOBBIE ObterParticipanteHobbiePorItemEParticipante(MA_PARTICIPANTE_HOBBIE hobbieparticipante)
 {
     return(this.Contexto.MA_PARTICIPANTE_HOBBIE.Where(l => l.cod_participante == hobbieparticipante.cod_participante && l.cod_item == hobbieparticipante.cod_item).SingleOrDefault());
 }
Beispiel #19
0
 public void RemoverHobbieDoParticipante(MA_PARTICIPANTE_HOBBIE hobbiedoparticipante)
 {
     this.RepositorioDeParcipanteHobbie.RemoverHobbieDoParticipante(hobbiedoparticipante);
 }
Beispiel #20
0
 public void AtualizarHobbieDoParticipante(MA_PARTICIPANTE_HOBBIE hobbieparticipante)
 {
     this.RepositorioDeParcipanteHobbie.AtualizarHobbieDoParticipante(hobbieparticipante);
 }
Beispiel #21
0
 public Boolean AtualizarHobbieDoParticipanteComRetorno(MA_PARTICIPANTE_HOBBIE hobbieparticipante)
 {
     return(this.RepositorioDeParcipanteHobbie.AtualizarHobbieDoParticipanteComRetorno(hobbieparticipante));
 }
Beispiel #22
0
        public ActionResult Delete(List <ParticipanteHobbie> listaparticipantehobbie)
        {
            JsonResult jsonResult;

            //Verifica se o registro é inválido e se sim, retorna com erro.
            if (listaparticipantehobbie == null)
            {
                jsonResult = Json(new
                {
                    codigo = -1
                }, JsonRequestBehavior.AllowGet);
            }
            else
            {
                if (this.GestorDeHobbieDeParticipante.VerificarSeExisteHobbieDeParticipantePorItemEParticipante(listaparticipantehobbie[0].CodItem, listaparticipantehobbie[0].CodParticipante))
                {
                    try
                    {
                        MA_PARTICIPANTE_HOBBIE participantehobbie = this.GestorDeHobbieDeParticipante.ObterParticipanteHobbiePorItemEParticipante(listaparticipantehobbie[0].CodItem, listaparticipantehobbie[0].CodParticipante);

                        if (participantehobbie.cod_status == 1)
                        {
                            MA_PARTICIPANTE_HOBBIE participantehobbiemodificado = new MA_PARTICIPANTE_HOBBIE();

                            participantehobbiemodificado.cod_p_hobbie     = participantehobbie.cod_p_hobbie;
                            participantehobbiemodificado.cod_participante = participantehobbie.cod_participante;
                            participantehobbiemodificado.cod_item         = participantehobbie.cod_item;

                            //Marca a relação como inativa
                            participantehobbiemodificado.cod_status = 2;

                            try
                            {
                                Boolean resultado = this.GestorDeHobbieDeParticipante.AtualizarHobbieDoParticipanteComRetorno(participantehobbiemodificado);

                                if (resultado)
                                {
                                    jsonResult = Json(new
                                    {
                                        codigo = participantehobbiemodificado.cod_p_hobbie
                                    }, JsonRequestBehavior.AllowGet);
                                }
                                else
                                {
                                    jsonResult = Json(new
                                    {
                                        codigo = -1
                                    }, JsonRequestBehavior.AllowGet);
                                }
                            }
                            catch (Exception e)
                            {
                                jsonResult = Json(new
                                {
                                    erro   = e.InnerException.ToString(),
                                    codigo = -1
                                }, JsonRequestBehavior.AllowGet);
                            }
                        }
                        else
                        {
                            jsonResult = Json(new
                            {
                                codigo = -1
                            }, JsonRequestBehavior.AllowGet);
                        }
                    }
                    catch (Exception e)
                    {
                        jsonResult = Json(new
                        {
                            erro   = e.InnerException.ToString(),
                            codigo = -1
                        }, JsonRequestBehavior.AllowGet);
                    }
                }
                else
                {
                    jsonResult = Json(new
                    {
                        codigo = -1
                    }, JsonRequestBehavior.AllowGet);
                }
            }

            jsonResult.MaxJsonLength = int.MaxValue;
            return(jsonResult);
        }