Example #1
0
        public ActionResult Editar(string id)
        {
            CommissionBL oBL    = new CommissionBL();
            int          pIntID = 0;

            int.TryParse(id, out pIntID);
            CommissionViewModel pCommissionViewModel = oBL.Obtener(pIntID);

            return(View(pCommissionViewModel));
        }
Example #2
0
        public JsonResult Verificar(int id_commission, string name)
        {
            CommissionBL oBL       = new CommissionBL();
            var          resultado = oBL.VerificarDuplicado(id_commission, name);

            return(Json(new
            {
                // this is what datatables wants sending back
                valido = resultado,
            }));
        }
Example #3
0
        public JsonResult Eliminar(int id)
        {
            CommissionBL oCommissionBL = new CommissionBL();

            oCommissionBL.Eliminar(id);

            return(Json(new
            {
                // this is what datatables wants sending back
                status = "1",
            }));
        }
Example #4
0
        public ActionResult Editar([Bind(Include = "commission_id,name")] CommissionViewModel pCommissionViewModel)
        {
            // TODO: Add insert logic here

            if (pCommissionViewModel == null)
            {
                return(HttpNotFound());
            }
            CommissionBL oCommissionBL = new CommissionBL();

            pCommissionViewModel.user_id_modified = AuthorizeUserAttribute.UsuarioLogeado().user_id;
            oCommissionBL.Modificar(pCommissionViewModel);
            return(RedirectToAction("Index"));
        }
Example #5
0
        public JsonResult ObtenerLista(DataTableAjaxPostModel ofilters)//DataTableAjaxPostModel model
        {
            CommissionBL oCommissionBL = new CommissionBL();
            //CommissionFiltersViewModel ofilters = new CommissionFiltersViewModel();
            GridModel <CommissionViewModel> grid = oCommissionBL.ObtenerLista(ofilters);

            return(Json(new
            {
                // this is what datatables wants sending back
                draw = ofilters.draw,
                recordsTotal = grid.total,
                recordsFiltered = grid.recordsFiltered,
                data = grid.rows
            }));
        }
Example #6
0
        public ActionResult Crear([Bind(Include = "commission_id,name")] CommissionViewModel pCommissionViewModel)
        {
            // TODO: Add insert logic here

            if (pCommissionViewModel == null)
            {
                return(HttpNotFound());
            }
            pCommissionViewModel.commission_id   = 0;
            pCommissionViewModel.user_id_created = AuthorizeUserAttribute.UsuarioLogeado().user_id;

            CommissionBL oBL = new CommissionBL();

            oBL.Agregar(pCommissionViewModel);
            return(RedirectToAction("Index"));
        }
Example #7
0
        public JsonResult Crear([Bind(Include = "draft_law_id,draft_law_number,title,author,origin,date_presentation,date_presentation_text,commission_id,debate_speaker,debate_speaker2,debate_speaker3,debate_speaker4,status,status_comment,interest_area_id,initiative,summary,link")] DraftLawViewModel pDraftLawViewModel)
        {
            // TODO: Add insert logic here


            if (pDraftLawViewModel == null)
            {
                // return HttpNotFound();

                return(Json(new
                {
                    message_error = "Datos inavalidos",
                    status = "0",
                }));
            }
            pDraftLawViewModel.date_presentation = DateTime.ParseExact(pDraftLawViewModel.date_presentation_text, "dd/MM/yyyy", CultureInfo.InvariantCulture);
            pDraftLawViewModel.draft_law_id      = 0;

            pDraftLawViewModel.user_id_created = AuthorizeUserAttribute.UsuarioLogeado().user_id;

            pDraftLawViewModel.commission    = "";
            pDraftLawViewModel.interest_area = "";
            List <ImportError>       oErrores = null;
            DraftLawBL               oBL      = new DraftLawBL();
            List <DraftLawViewModel> lista    = new List <DraftLawViewModel>();

            lista.Add(pDraftLawViewModel);
            PeriodBL        oPeriodBL = new PeriodBL();
            PeriodViewModel oPeriod   = oPeriodBL.ObtenerVigente();

            oErrores = ValidarPeriodo(oPeriod, oErrores);
            if (oErrores.Count > 0)
            {
                return(Json(new { successfully = 0, errores = oErrores }));
            }

            if (VerificarPonentes(lista, out oErrores))
            {
                DraftLawBL               oDraftLawBL       = new DraftLawBL();
                CommissionBL             oCommissionBL     = new CommissionBL();
                InterestAreaBL           oInterestAreaBL   = new InterestAreaBL();
                DraftLawStatusBL         oDraftLawStatusBL = new DraftLawStatusBL();
                OriginBL                 oOriginBL         = new OriginBL();
                Dictionary <string, int> commisions        = new Dictionary <string, int>();
                Dictionary <string, int> origins           = oOriginBL.ObtenerDiccionarioPorNombre(lista.Select(a => a.origin).Distinct().ToList(), AuthorizeUserAttribute.UsuarioLogeado().user_id);
                Dictionary <string, int> interest_areas    = new Dictionary <string, int>();
                Dictionary <string, DraftLawStatusViewModel> draftlaw_status = oDraftLawStatusBL.ObtenerDiccionarioPorNombre(lista.Select(a => a.status).Distinct().ToList(), AuthorizeUserAttribute.UsuarioLogeado().user_id);

                oDraftLawBL.Import(oPeriod, lista, origins, commisions, interest_areas, draftlaw_status, AuthorizeUserAttribute.UsuarioLogeado().user_id);
                // NotificacionNuevoProyectoLey(lista);
            }


            // oBL.Agregar(pDraftLawViewModel);
            if (oErrores.Count == 0)
            {
                return(Json(new { successfully = 1 }));
            }
            else
            {
                return(Json(new { successfully = 0, errores = oErrores }));
            }

            // return RedirectToAction("Index");
        }
Example #8
0
        public ActionResult UploadFiles()
        {
            List <ImportError> oErrores = null;

            // Checking no of files injected in Request object
            if (Request.Files.Count > 0)
            {
                try
                {
                    //  Get all files from Request object
                    HttpFileCollectionBase files = Request.Files;
                    for (int i = 0; i < files.Count; i++)
                    {
                        //string path = AppDomain.CurrentDomain.BaseDirectory + "Uploads/";
                        //string filename = Path.GetFileName(Request.Files[i].FileName);

                        HttpPostedFileBase file  = files[i];
                        string             fname = Guid.NewGuid().ToString() + ".xlsx";

                        fname = Path.Combine(Server.MapPath("~/Uploads/"), fname);
                        file.SaveAs(fname);
                        DataTable       dt        = Util.ReadExcelToDataTable(fname);
                        PeriodBL        oPeriodBL = new PeriodBL();
                        PeriodViewModel oPeriod   = oPeriodBL.ObtenerVigente();

                        oErrores = ValidarPeriodo(oPeriod, oErrores);
                        List <DraftLawViewModel> lista = new List <DraftLawViewModel>();
                        if (oErrores.Count == 0)
                        {
                            lista = ConvertirDatatable(dt, out oErrores);
                        }
                        if (oErrores.Count == 0)
                        {
                            if (VerificarPonentes(lista, out oErrores))
                            {
                                DraftLawBL               oDraftLawBL       = new DraftLawBL();
                                CommissionBL             oCommissionBL     = new CommissionBL();
                                InterestAreaBL           oInterestAreaBL   = new InterestAreaBL();
                                DraftLawStatusBL         oDraftLawStatusBL = new DraftLawStatusBL();
                                OriginBL                 oOriginBL         = new OriginBL();
                                Dictionary <string, int> commisions        = oCommissionBL.ObtenerDiccionarioPorNombre(lista.Select(a => a.commission).Distinct().ToList(), AuthorizeUserAttribute.UsuarioLogeado().user_id);
                                Dictionary <string, int> origins           = oOriginBL.ObtenerDiccionarioPorNombre(lista.Select(a => a.origin).Distinct().ToList(), AuthorizeUserAttribute.UsuarioLogeado().user_id);
                                Dictionary <string, int> interest_areas    = oInterestAreaBL.ObtenerDiccionarioPorNombre(lista.Select(a => a.interest_area).Distinct().ToList(), AuthorizeUserAttribute.UsuarioLogeado().user_id);
                                Dictionary <string, DraftLawStatusViewModel> draftlaw_status = oDraftLawStatusBL.ObtenerDiccionarioPorNombre(lista.Select(a => a.status).Distinct().ToList(), AuthorizeUserAttribute.UsuarioLogeado().user_id);

                                oDraftLawBL.Import(oPeriod, lista, origins, commisions, interest_areas, draftlaw_status, AuthorizeUserAttribute.UsuarioLogeado().user_id);
                                // NotificacionNuevoProyectoLey(lista);
                            }
                        }
                    }
                    if (oErrores.Count == 0)
                    {
                        return(Json(new { successfully = 1 }));
                    }
                    else
                    {
                        return(Json(new { successfully = 0, errores = oErrores }));
                    }
                }
                catch (Exception ex)
                {
                    logger.Error(ex);
                    if (ex.Data.Contains("RepositoryMessage"))
                    {
                        logger.Error(ex.Data["RepositoryMessage"].ToString());
                    }
                    return(Json(new { successfully = -1, message = "Ha ocurrido un error. Detalle error: " + ex.Message }));
                }
            }
            else
            {
                return(Json("No files selected."));
            }
        }