예제 #1
0
        public ActionResult CadastrarComponente(ComponenteViewModel viewModel, FormCollection collection)
        {
            Componente model = null;

            try
            {
                if (BL.Componente.Get(a => a.CH == viewModel.CH && a.Nome == viewModel.Nome).Any())
                {
                    TempData["Error"]        = true;
                    TempData["ErrorMessage"] = "Erro ao cadastrar Componente. Já existe um componente com o mesmo nome e carga horária.";
                    return(RedirectToAction("Index"));
                }
                var   teste = collection["tipoAmbiente"].Split(',');
                var   arrayIdAreasAtuacao = Array.ConvertAll(collection["idsAreaAtuacao"].Split(';'), t => int.Parse(t));
                int[] idTipoAmbiente      = Array.ConvertAll(teste, s => int.Parse(s));
                model = ComponenteViewModel.MapToModel(viewModel);
                var areas      = BL.AreaAtuacao.Get(a => arrayIdAreasAtuacao.Contains(a.IdAreaAtuacao), null, "").ToList();
                var componente = BL.Componente.InserirComponente(model, idTipoAmbiente);
                BL.Componente.AtualizarAreAtuacaoComponente(componente, areas);

                TempData["Sucesso"]        = true;
                TempData["SucessoMessage"] = "Cadastro de Componente realizado com sucesso.";
            }
            catch (Exception ex)
            {
                TempData["Error"]        = true;
                TempData["ErrorMessage"] = (ex.GetType().Name == "CustomException") ? ex.Message : "Erro ao cadastrar Componente.";

                Logging.getInstance().Error(TempData["ErrorMessage"].ToString(), ex);
            }

            return(RedirectToAction("Index"));
        }
예제 #2
0
        public ActionResult EditarComponente(ComponenteViewModel viewModel, FormCollection collection)
        {
            try
            {
                var   tiposAmbientesId    = collection["tipoAmbiente"].Split(',');
                int[] idTipoAmbiente      = Array.ConvertAll(tiposAmbientesId, s => int.Parse(s));
                var   arrayIdAreasAtuacao = Array.ConvertAll(collection["idsAreaAtuacao"].Split(';'), t => int.Parse(t));

                var model = ComponenteViewModel.MapToModel(viewModel);
                var areas = BL.AreaAtuacao.Get(a => arrayIdAreasAtuacao.Contains(a.IdAreaAtuacao), null, "").ToList();
                BL.Componente.AtualizarComponente(model, idTipoAmbiente);
                BL.Componente.AtualizarAreAtuacaoComponente(model, areas);

                TempData["Sucesso"]        = true;
                TempData["SucessoMessage"] = "Edição de Componente realizada com sucesso.";
            }
            catch (Exception ex)
            {
                TempData["Error"]        = true;
                TempData["ErrorMessage"] = (ex.GetType().Name == "CustomException") ? ex.Message : "Erro ao editar Componente.";
                Logging.getInstance().Error(TempData["ErrorMessage"].ToString(), ex);
            }

            return(RedirectToAction("Index"));
        }
예제 #3
0
        public ActionResult EditarMatriz(int id)
        {
            MatrizViewModel matrizViewModel = null;

            try
            {
                var item = BL.Matriz.Get(a => a.IdMatriz == id, null, "Modulo, Modulo.Componente").FirstOrDefault();
                matrizViewModel = MatrizViewModel.MapToViewModel(item);

                matrizViewModel.ListaModalidades = ModalidadeViewModel.MapToListViewModel((BL.Modalidade.Get()).ToList());
                matrizViewModel.ListaAreaAtuacao = AreaAtuacaoViewModel.MapToListViewModel((BL.AreaAtuacao.Get()).ToList());
                matrizViewModel.ListaCBO         = CBOViewModel.MapToListViewModel((BL.CBO.Get()).ToList());
                // Listar componentes
                matrizViewModel.ListaReprovacaoMatriz = BL.ReprovacaoMatriz.Get(a => a.IdMatriz == matrizViewModel.IdMatriz).ToList();
                MatrizListarComponentesViewModel viewModel = new MatrizListarComponentesViewModel();
                viewModel.Matriz = id;
                viewModel.Filtro = Request.QueryString["filtro"];

                var lista = BL.Componente.BuscarComponentesPor(viewModel.Filtro, 1, (int)PaginacaoEnum.NumeroElementos);
                viewModel.ListaViewModel = ComponenteViewModel.MapToListViewModel(lista);

                matrizViewModel.ListaComponente = viewModel;
            }
            catch (Exception ex)
            {
                TempData["Error"]        = true;
                TempData["ErrorMessage"] = "Erro ao carregar a página";
                Logging.getInstance().Error("Erro ao carregar página EditarMatriz", ex);
            }
            matrizViewModel.ListaReprovacaoMatriz.OrderByDescending(a => a.IdReprovacaoMatriz);
            return(View(matrizViewModel));
        }
        public IHttpActionResult ModificarComponente(ComponenteViewModel modelo)
        {
            var data = Repositorio.Actualizar(modelo);

            if (data == 0)
            {
                return(BadRequest("Error en la actualización."));
            }
            return(Ok(data));
        }
        public IHttpActionResult DeleteComponente(ComponenteViewModel modelo)
        {
            var data = Repositorio.Borrar(modelo);

            if (data == 0)
            {
                return(BadRequest("No se ha eliminado el registro."));
            }
            return(Ok(data));
        }
        public IHttpActionResult AddComponente(ComponenteViewModel modelo)
        {
            var data = Repositorio.Add(modelo);

            if (data == null)
            {
                return(BadRequest("Error en la creación de un nuevo componente"));
            }
            modelo.ID = data.ID;
            return(Created("Componente Creado", data));
        }
예제 #7
0
        public ActionResult BuscarComponentes(string filtro, int idAreaAtuacao)
        {
            MatrizViewModel matrizViewModel        = new MatrizViewModel();
            MatrizListarComponentesViewModel model = new MatrizListarComponentesViewModel();

            //#refatorar: Codigo duplicado
            var componentes = BL.Componente.BuscarComponentesPorAreaAtuacao(idAreaAtuacao.ToString());

            componentes = componentes.Where(c => c.Nome.ToLower().Contains(filtro.ToLower())).ToList();

            model.ListaViewModel            = ComponenteViewModel.MapToListViewModel(componentes);
            model.Filtro                    = filtro;
            matrizViewModel.ListaComponente = model;
            return(PartialView("_BuscarModuloComponentes", matrizViewModel));
        }
예제 #8
0
        //
        // GET: /Componente/
        public ActionResult Index(FiltrosComponente filtro = null)
        {
            filtro = filtro == null ? new FiltrosComponente() : filtro;
            try
            {
                filtro.Componentes = ComponenteViewModel.MapToListViewModel(BL.Componente.Get(null, null, "TipoAmbiente").ToList());
            }
            catch (Exception ex)
            {
                TempData["Error"]        = true;
                TempData["ErrorMessage"] = "Erro ao carregar a página";
                Logging.getInstance().Error("Erro ao carregar página de componentes", ex);

                return(View());
            }

            return(View(filtro));
        }
예제 #9
0
        public ActionResult ModalComponente()
        {
            ComponenteViewModel viewModel = null;

            try
            {
                viewModel = new ComponenteViewModel();
                viewModel.ListaAreaAtuacao  = AreaAtuacaoViewModel.MapToListViewModel(BL.AreaAtuacao.Get().ToList());
                viewModel.ListaTipoAmbiente = TipoAmbienteViewModel.MapToListViewModel(BL.TipoAmbiente.Get(a => true, b => b.OrderBy(c => c.Descr), "").ToList());
            }
            catch (Exception ex)
            {
                TempData["ErrorMessage"] = "Erro ao carregar a página";
                TempData["Error"]        = true;
                Logging.getInstance().Error("Erro ao carregar página a página CadastrarComponente", ex);
            }

            return(PartialView(viewModel));
        }
예제 #10
0
        //
        // GET: /DocenteViewModels/Edit/5
        public ActionResult EditarDocente(int id)
        {
            DocenteViewModel docenteViewModel = null;

            try
            {
                //var lista = this.speDominioService.GetAreaAtuacaoAll();


                //var docente = this.speDominioService.GetFilteredDocente(a => a.IdDocente == id, null, "Componente").SingleOrDefault();
                var docente = BL.Docente.Get(a => a.IdDocente == id, null, "Componente,AreaAtuacao").SingleOrDefault();
                docenteViewModel = DocenteViewModel.MapToViewModel(docente);
                docenteViewModel.listaAreaAtuacao = AreaAtuacaoViewModel.MapToListViewModel(BL.AreaAtuacao.Get().ToList());
                //docenteViewModel.listaAreaAtuacaoDocente =
                docenteViewModel.AgendaComponente = new List <AgendaComponenteViewModel>();
                docenteViewModel.TipoContrato     = TipoContratoViewModel.MapToListViewModel(BL.TipoContrato.Get().ToList());
                docenteViewModel.Empresa          = EmpresaViewModel.MapToListViewModel(BL.Empresa.Get().ToList());


                docenteViewModel.ListaComponentes = new List <ComponenteViewModel>();

                //var listaCompoente = ComponenteViewModel.MapToListViewModel(this.speDominioService.BuscarComponentesPor("", 1, 1000));
                var listaCompoente = ComponenteViewModel.MapToListViewModel(BL.Componente.BuscarComponentesPor("", 1, 1000));

                foreach (ComponenteViewModel item in listaCompoente)
                {
                    if (!docenteViewModel.ListaComponentes.Any(a => StringExtension.GenerateSlug(a.Nome).Contains(StringExtension.GenerateSlug(item.Nome))) && docenteViewModel.ListaComponentes.Count < 10)
                    {
                        docenteViewModel.ListaComponentes.Add(item);
                    }
                }

                return(View(docenteViewModel));
            }
            catch (Exception ex)
            {
                TempData["Error"]        = true;
                TempData["ErrorMessage"] = "Erro ao carregar a página";
                Logging.getInstance().Error("Erro ao carregar página EditarDocente", ex);
            }
            return(View(docenteViewModel));
        }
예제 #11
0
        public ActionResult ModalCadastrarComponente(ComponenteViewModel viewModel)
        {
            Componente          inserido          = new Componente();
            Componente          model             = null;
            ComponenteViewModel retornoComponente = new ComponenteViewModel();

            try
            {
                var idTipoAmbiente = Array.ConvertAll(viewModel.TipoAmbienteId.Split(','), a => int.Parse(a));
                var idAreaAtuacao  = Array.ConvertAll(viewModel.AreaAtuacaoId.Split(','), a => int.Parse(a));

                List <AreaAtuacao> listaAreaAtuacao = BL.AreaAtuacao.Get(a => idAreaAtuacao.Contains(a.IdAreaAtuacao)).ToList();

                model    = ComponenteViewModel.MapToModel(viewModel);
                inserido = BL.Componente.InserirComponente(model, idTipoAmbiente);
                BL.Componente.AtualizarAreAtuacaoComponente(inserido, listaAreaAtuacao);

                inserido = BL.Componente.GetById(inserido.IdComponente);

                retornoComponente = ComponenteViewModel.MapToViewModel(inserido);
                retornoComponente.TipoAmbiente = null;
                retornoComponente.AreaAtuacao  = null;


                TempData["Sucesso"]        = true;
                TempData["SucessoMessage"] = "Cadastro de Componente realizado com sucesso.";
            }
            catch (Exception ex)
            {
                bool validation = (ex.GetType().Name == "CustomException");
                if (!validation)
                {
                    TempData["Error"] = true;
                }
                TempData["ErrorMessage"] = validation ? ex.Message : "Erro ao cadastrar Componente.";
                Logging.getInstance().Error(TempData["ErrorMessage"].ToString(), ex);

                return(Json("false", JsonRequestBehavior.AllowGet));
            }

            return(Json(retornoComponente, JsonRequestBehavior.AllowGet));
        }
예제 #12
0
        public ViewResult DetalharComponente(int id)
        {
            ComponenteViewModel componenteViewModel = null;

            try
            {
                var componente = BL.Componente.GetById(id);
                componenteViewModel = ComponenteViewModel.MapToViewModel(componente);
            }
            catch (Exception ex)
            {
                TempData["ErrorMessage"] = "Erro ao carregar a página";
                TempData["Error"]        = true;
                Logging.getInstance().Error("Erro ao carregar página a página DetalharComponente", ex);

                return(View());
            }

            return(View(componenteViewModel));
        }
예제 #13
0
        public ActionResult EditarComponente(int id)
        {
            ComponenteViewModel componenteViewModel = null;

            try
            {
                var componente = BL.Componente.Get(a => a.IdComponente == id, null, "TipoAmbiente,AreaAtuacao").SingleOrDefault();

                componenteViewModel = ComponenteViewModel.MapToViewModel(componente);
                componenteViewModel.ListaTipoAmbiente = TipoAmbienteViewModel.MapToListViewModel(BL.TipoAmbiente.Get(a => true, b => b.OrderBy(c => c.Descr), "").ToList());
                componenteViewModel.ListaAreaAtuacao  = AreaAtuacaoViewModel.MapToListViewModel(BL.AreaAtuacao.Get().ToList());
            }
            catch (Exception ex)
            {
                TempData["ErrorMessage"] = "Erro ao carregar a página";
                TempData["Error"]        = true;
                Logging.getInstance().Error("Erro ao carregar página a página EditarComponente", ex);
            }

            return(View(componenteViewModel));
        }
예제 #14
0
        //
        // GET: /DocenteViewModels/Create
        public ActionResult CadastrarDocente()
        {
            try
            {
                //var lista = this.speDominioService.GetAreaAtuacaoAll();



                //var lista = AreaAtuacaoViewModel.MapToListViewModel((from u in this.Context.AreaAtuacao
                //                                                     select u).ToList());
                DocenteViewModel docenteViewModel = new DocenteViewModel();
                docenteViewModel.listaAreaAtuacao = AreaAtuacaoViewModel.MapToListViewModel(BL.AreaAtuacao.Get().ToList());
                docenteViewModel.AgendaComponente = new List <AgendaComponenteViewModel>();
                docenteViewModel.TipoContrato     = TipoContratoViewModel.MapToListViewModel(BL.TipoContrato.Get().ToList());
                docenteViewModel.Empresa          = EmpresaViewModel.MapToListViewModel(BL.Empresa.Get().ToList());

                docenteViewModel.ListaComponentes = new List <ComponenteViewModel>();

                //var listaCompoente = ComponenteViewModel.MapToListViewModel(this.speDominioService.BuscarComponentesPor("", 1, 1000));
                var listaCompoente = ComponenteViewModel.MapToListViewModel(BL.Componente.BuscarComponentesPor("", 1, 1000));

                foreach (ComponenteViewModel item in listaCompoente)
                {
                    if (!docenteViewModel.ListaComponentes.Any(a => StringExtension.GenerateSlug(a.Nome).Contains(StringExtension.GenerateSlug(item.Nome))) && docenteViewModel.ListaComponentes.Count < 10)
                    {
                        docenteViewModel.ListaComponentes.Add(item);
                    }
                }

                return(View(docenteViewModel));
            }
            catch (Exception ex)
            {
                TempData["Error"]        = true;
                TempData["ErrorMessage"] = "Erro ao carregar a página";
                Logging.getInstance().Error("Erro ao carregar página CadastrarDocente", ex);
                return(View());
            }
        }