コード例 #1
0
        //Cadastro do participante no banco
        protected void Save(object sender, DirectEventArgs e)
        {
            MA_PARTICIPANTE_APRENDER aprenderparticipante = new MA_PARTICIPANTE_APRENDER();

            aprenderparticipante.cod_participante = Int32.Parse(cod_participanteId.SelectedItem.Value);
            aprenderparticipante.cod_item         = Int32.Parse(cod_itemId.SelectedItem.Value);
            aprenderparticipante.cod_s_relacao    = Int32.Parse(cod_s_relacaoId.SelectedItem.Value);


            //Caso o form não possui código, será inserido um novo aprender de participante
            if (cod_p_aprenderId.Text == "")
            {
                this.GestorDeParticipanteAprender.InserirNovoAprendizadoDeParticipante(aprenderparticipante);
                ParticipanteAprenderWindowId.Close();
                LimpaForm();
            }
            //Caso contrário, o form será atualizado
            else
            {
                aprenderparticipante.cod_p_aprender = Int32.Parse(cod_p_aprenderId.Text);
                this.GestorDeParticipanteAprender.AtualizarAprendizadoDeParticipante(aprenderparticipante);
                ParticipanteAprenderWindowId.Close();
                LimpaForm();
            }
        }
コード例 #2
0
        public void AtualizarAprendizadoDeParticipanteSemConferencia(MA_PARTICIPANTE_APRENDER participanteaprender)
        {
            MIMACHEREntities contexto = new MIMACHEREntities();

            contexto.Entry(participanteaprender).State = EntityState.Modified;
            contexto.SaveChanges();
        }
コード例 #3
0
        public ActionResult Update(List <ParticipanteAprender> listaparticipanteaprender)
        {
            JsonResult jsonResult;

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

                jsonResult.MaxJsonLength = int.MaxValue;
                return(jsonResult);
            }
            foreach (ParticipanteAprender pe in listaparticipanteaprender)
            {
                MA_PARTICIPANTE_APRENDER participanteaprender = new MA_PARTICIPANTE_APRENDER();
                participanteaprender.cod_p_aprender   = pe.cod_p_aprender;
                participanteaprender.cod_participante = pe.cod_participante;
                participanteaprender.cod_item         = pe.cod_item;
                participanteaprender.cod_s_relacao    = pe.cod_s_relacao;

                GestorDeParticipanteAprender.InserirNovoAprendizadoDeParticipante(participanteaprender);
            }

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

            jsonResult.MaxJsonLength = int.MaxValue;
            return(jsonResult);
        }
コード例 #4
0
        //Exclui determinado participante do banco de dados
        protected void Delete(object sender, DirectEventArgs e)
        {
            MA_PARTICIPANTE_APRENDER aprenderparticipante = this.GestorDeParticipanteAprender.ObterAprendizadoDoParticipantePorId(Int32.Parse(cod_p_aprenderId.Text));

            this.GestorDeParticipanteAprender.RemoverAprendizadoDeParticipante(aprenderparticipante);
            LimpaForm();
        }
コード例 #5
0
 public Boolean VerificarSeExisteRelacaoDeParticipanteAprender(MA_PARTICIPANTE_APRENDER participanteaprender)
 {
     if (ObterAprendizadoDeParticipantePorItemEParticipante(participanteaprender) != null)
     {
         return(true);
     }
     return(false);
 }
コード例 #6
0
        public ActionResult Add(List <ParticipanteAprender> listaparticipanteaprender)
        {
            JsonResult jsonResult;

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

                jsonResult.MaxJsonLength = int.MaxValue;
                return(jsonResult);
            }
            else
            {
                MA_PARTICIPANTE_APRENDER participanteaprender = new MA_PARTICIPANTE_APRENDER();

                participanteaprender.cod_participante = listaparticipanteaprender[0].CodParticipante;
                participanteaprender.cod_item         = listaparticipanteaprender[0].CodItem;

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

                try
                {
                    Boolean resultado = GestorDeParticipanteAprender.InserirNovoAprendizadoDeParticipanteComRetorno(participanteaprender);

                    if (resultado)
                    {
                        jsonResult = Json(new
                        {
                            codigo = participanteaprender.cod_participante
                        }, 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);
        }
コード例 #7
0
        public ActionResult Delete(List <ParticipanteAprender> listaparticipanteaprender)
        {
            JsonResult jsonResult;

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

                jsonResult.MaxJsonLength = int.MaxValue;
                return(jsonResult);
            }
            else
            {
                foreach (ParticipanteAprender pa in listaparticipanteaprender)
                {
                    if (pa.cod_s_relacao == 2)
                    {
                        MA_PARTICIPANTE_APRENDER participanteaprender = new MA_PARTICIPANTE_APRENDER();

                        participanteaprender.cod_p_aprender   = pa.cod_p_aprender;
                        participanteaprender.cod_participante = pa.cod_participante;
                        participanteaprender.cod_item         = pa.cod_item;
                        participanteaprender.cod_s_relacao    = pa.cod_s_relacao;

                        this.GestorDeParticipanteAprender.InserirNovoAprendizadoDeParticipante(participanteaprender);

                        jsonResult = Json(new
                        {
                            codigo = participanteaprender.cod_p_aprender
                        }, JsonRequestBehavior.AllowGet);

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

                jsonResult = Json(new
                {
                    codigo = -1
                }, JsonRequestBehavior.AllowGet);

                jsonResult.MaxJsonLength = int.MaxValue;
                return(jsonResult);
            }
        }
コード例 #8
0
        public void AtualizarAprendizadoDeParticipante(MA_PARTICIPANTE_APRENDER participanteaprender)
        {
            if (!VerificarSeExisteRelacaoDeParticipanteAprender(participanteaprender))
            {
                AtualizarAprendizadoDeParticipanteSemConferencia(participanteaprender);
            }
            else
            {
                MA_PARTICIPANTE_APRENDER participanteaprenderconferencia = ObterAprendizadoDeParticipantePorItemEParticipante(participanteaprender);

                if (participanteaprenderconferencia.cod_status != participanteaprender.cod_status)
                {
                    AtualizarAprendizadoDeParticipanteSemConferencia(participanteaprender);
                }
            }
        }
コード例 #9
0
        public void InserirNovoAprendizadoDeParticipante(MA_PARTICIPANTE_APRENDER participanteaprender)
        {
            if (!VerificarSeExisteRelacaoDeParticipanteAprender(participanteaprender))
            {
                this.Contexto.MA_PARTICIPANTE_APRENDER.Add(participanteaprender);
                this.Contexto.SaveChanges();
            }
            else
            {
                MA_PARTICIPANTE_APRENDER participanteaprenderconferencia = ObterAprendizadoDeParticipantePorItemEParticipante(participanteaprender);

                if (participanteaprenderconferencia.cod_status != participanteaprender.cod_status)
                {
                    AtualizarAprendizadoDeParticipanteSemConferencia(participanteaprender);
                }
            }
        }
コード例 #10
0
        public Boolean InserirNovoAprendizadoDeParticipanteComRetorno(MA_PARTICIPANTE_APRENDER participanteaprender)
        {
            if (!VerificarSeExisteRelacaoDeParticipanteAprender(participanteaprender))
            {
                this.Contexto.MA_PARTICIPANTE_APRENDER.Add(participanteaprender);
                this.Contexto.SaveChanges();

                return(true);
            }
            else
            {
                MA_PARTICIPANTE_APRENDER participanteaprenderconferencia = ObterAprendizadoDeParticipantePorItemEParticipante(participanteaprender);

                if (participanteaprenderconferencia.cod_status != participanteaprender.cod_status)
                {
                    return(AtualizarAprendizadoDeParticipanteComRetorno(participanteaprender));
                }
                else
                {
                    return(false);
                }
            }
        }
コード例 #11
0
        public Boolean AtualizarAprendizadoDeParticipanteComRetorno(MA_PARTICIPANTE_APRENDER participanteaprender)
        {
            if (!VerificarSeExisteRelacaoDeParticipanteAprender(participanteaprender))
            {
                AtualizarAprendizadoDeParticipanteSemConferencia(participanteaprender);

                return(true);
            }
            else
            {
                MA_PARTICIPANTE_APRENDER participanteaprenderconferencia = ObterAprendizadoDeParticipantePorItemEParticipante(participanteaprender.cod_item, participanteaprender.cod_participante);

                if (participanteaprenderconferencia.cod_status != participanteaprender.cod_status)
                {
                    AtualizarAprendizadoDeParticipanteSemConferencia(participanteaprender);

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
コード例 #12
0
 public List <MA_PARTICIPANTE_APRENDER> ObterTodosOsAprendizadoDeParticipantePorPorItemPaginadosPorVinteRegistros(MA_PARTICIPANTE_APRENDER participanteaprender)
 {
     return(this.RepositorioDeAprendizadoDeParticipante.ObterTodosOsAprendizadoDeParticipantePorPorItemPaginadosPorVinteRegistros(participanteaprender));
 }
コード例 #13
0
 public void InserirNovoAprendizadoDeParticipante(MA_PARTICIPANTE_APRENDER participanteaprender)
 {
     this.RepositorioDeAprendizadoDeParticipante.InserirNovoAprendizadoDeParticipante(participanteaprender);
 }
コード例 #14
0
 public List <MA_PARTICIPANTE_APRENDER> ObterTodosOsAprendizadoDeParticipantePorPorItemPaginadosPorVinteRegistros(MA_PARTICIPANTE_APRENDER participanteaprender)
 {
     return(this.Contexto.MA_PARTICIPANTE_APRENDER.Where(l => l.cod_item == participanteaprender.cod_item && l.cod_status == 1).Skip(participanteaprender.cod_p_aprender).Take(20).ToList());
 }
コード例 #15
0
 public MA_PARTICIPANTE_APRENDER ObterAprendizadoDeParticipantePorItemEParticipante(MA_PARTICIPANTE_APRENDER participanteaprender)
 {
     return(this.Contexto.MA_PARTICIPANTE_APRENDER.Where(l => l.cod_participante == participanteaprender.cod_participante && l.cod_item == participanteaprender.cod_item).SingleOrDefault());
 }
コード例 #16
0
 public void AtualizarAprendizadoDeParticipante(MA_PARTICIPANTE_APRENDER participanteaprender)
 {
     this.RepositorioDeAprendizadoDeParticipante.AtualizarAprendizadoDeParticipante(participanteaprender);
 }
コード例 #17
0
        public ActionResult Delete(List <ParticipanteAprender> listaparticipanteaprender)
        {
            JsonResult jsonResult;

            //Verifica se o registro é inválido e se sim, retorna com erro.
            if (listaparticipanteaprender == null)
            {
                jsonResult = Json(new
                {
                    codigo = -1
                }, JsonRequestBehavior.AllowGet);
            }
            else
            {
                if (this.GestorDeParticipanteAprender.VerificarSeExisteRelacaoUsuarioPorItemEParticipante(listaparticipanteaprender[0].CodItem, listaparticipanteaprender[0].CodParticipante))
                {
                    try
                    {
                        MA_PARTICIPANTE_APRENDER participanteaprender = this.GestorDeParticipanteAprender.ObterAprendizadoDeParticipantePorItemEParticipante(listaparticipanteaprender[0].CodItem, listaparticipanteaprender[0].CodParticipante);

                        if (participanteaprender.cod_status == 1)
                        {
                            MA_PARTICIPANTE_APRENDER participanteaprendermodificado = new MA_PARTICIPANTE_APRENDER();

                            participanteaprendermodificado.cod_p_aprender   = participanteaprender.cod_p_aprender;
                            participanteaprendermodificado.cod_participante = participanteaprender.cod_participante;
                            participanteaprendermodificado.cod_item         = participanteaprender.cod_item;

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

                            try
                            {
                                Boolean resultado = this.GestorDeParticipanteAprender.AtualizarAprendizadoDeParticipanteComRetorno(participanteaprendermodificado);

                                if (resultado)
                                {
                                    jsonResult = Json(new
                                    {
                                        codigo = participanteaprendermodificado.cod_p_aprender
                                    }, 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);
        }
コード例 #18
0
 public Boolean AtualizarAprendizadoDeParticipanteComRetorno(MA_PARTICIPANTE_APRENDER participanteaprender)
 {
     return(this.RepositorioDeAprendizadoDeParticipante.AtualizarAprendizadoDeParticipanteComRetorno(participanteaprender));
 }
コード例 #19
0
 public void RemoverAprendizadoDeParticipante(MA_PARTICIPANTE_APRENDER participanteaprender)
 {
     this.Contexto.MA_PARTICIPANTE_APRENDER.Remove(participanteaprender);
     this.Contexto.SaveChanges();
 }