Esempio n. 1
0
        public ActionResult Logout()
        {
            AutenticationManager.Logout();
            Response.Redirect(Url.Action("Login", "Seguridad"), true);

            return(View());
        }
Esempio n. 2
0
        public ActionResult GetPerfil(int id)
        {
            List <PerfilViewModel> lstModel      = new List <PerfilViewModel>();
            List <MProfile>        lstResult     = null;
            UserIdentity           objUserIdenty = AutenticationManager.GetUser();


            MProfile entPerfiles = new MProfile();

            entPerfiles.UserId = Convert.ToInt32(AutenticationManager.GetUser().IdUsuario);

            lstResult = new WebApiProfile().GetProfilesByUser(entPerfiles);

            foreach (var item in lstResult)
            {
                lstModel.Add(new PerfilViewModel {
                    Perfil = item.Description, Id = item.ProfileId.ToString()
                });
            }
            ;


            if ((objUserIdenty.IdEmpresa != id || objUserIdenty.IdPerfil == 0) && lstModel.Count > 0)
            {
                objUserIdenty.IdPerfil = Convert.ToInt32(lstModel.FirstOrDefault().Id);
            }

            // Guardo la empresa
            objUserIdenty.IdEmpresa = id;

            AutenticationManager.SaveLogin(objUserIdenty);
            return(PartialView("_Perfil", lstModel));
        }
Esempio n. 3
0
        public ActionResult Register(LoadProjectsViewModel model, HttpPostedFileBase imageFile)
        {
            JSonResult objResult = new JSonResult();
            string     response  = string.Empty;

            try
            {
                Session objSession = new Session()
                {
                    UserId = AutenticationManager.GetUser().IdUsuario,
                };

                List <MProject>           entList     = new List <MProject>();
                List <ModelProjectResult> entListData = new List <ModelProjectResult>();
                entListData = (List <ModelProjectResult>)Session["ListProjects"];

                foreach (ModelProjectResult item in entListData)
                {
                    MProject mProject = new MProject();
                    mProject.ProjectCode = item.ProjectCode;
                    mProject.Description = item.Description;
                    mProject.Type        = item.Type;
                    mProject.Status      = item.Status;
                    mProject.StartDate   = Convert.ToInt32(Extension.ToFormatDateYYYYMMDD(item.StartDateStr));
                    mProject.EndDate     = Convert.ToInt32(Extension.ToFormatDateYYYYMMDD(item.EndDateStr));//item.EndDate;
                    mProject.Title       = item.Title;
                    mProject.AwardId     = item.AwardId;
                    mProject.AwardStatus = item.AwardStatus;
                    entList.Add(mProject);
                }

                response = new WebApiProject().InsertProject(entList, objSession);

                string statusCode    = response.Split('|')[0];
                string statusMessage = response.Split('|')[1];

                objResult.isError = statusCode.Equals("2");
                objResult.message = string.Format(MessageResource.SaveSuccess, "Projects");;
            }
            catch (Exception ex)
            {
                objResult.message = string.Format(MessageResource.SaveError + "Error :" + ex.Message, "Projects");
            }
            return(Json(objResult));
        }
Esempio n. 4
0
        public ActionResult Register(LoadProgamViewModel model, HttpPostedFileBase imageFile)
        {
            JSonResult objResult = new JSonResult();
            string     response  = string.Empty;

            try
            {
                Session objSession = new Session()
                {
                    UserId = AutenticationManager.GetUser().IdUsuario,
                };

                List <MProgramName>       entList     = new List <MProgramName>();
                List <ModelProgramResult> entListData = new List <ModelProgramResult>();
                entListData = (List <ModelProgramResult>)Session["ListPrograms"];

                foreach (ModelProgramResult item in entListData)
                {
                    MProgramName mFund = new MProgramName();
                    mFund.ProjectCode    = item.ProjectCode;
                    mFund.ProgramName    = item.ProgramName;
                    mFund.DonorCode      = item.DonorCode;
                    mFund.ProjectDetails = item.ProjectDetails;
                    mFund.TaskManager    = item.TaskManager;
                    mFund.Sector         = item.Sector;
                    entList.Add(mFund);
                }

                response = new WebApiProgram().InsertProgramName(entList, objSession);

                string statusCode    = response.Split('|')[0];
                string statusMessage = response.Split('|')[1];

                objResult.isError = statusCode.Equals("2");
                objResult.message = string.Format(MessageResource.SaveSuccess, "Program Names");;
            }
            catch (Exception ex)
            {
                objResult.message = string.Format(MessageResource.SaveError + "Error :" + ex.Message, "Program Names");
            }
            return(Json(objResult));
        }
Esempio n. 5
0
        public ActionResult Register(LoadFundsViewModel model, HttpPostedFileBase imageFile)
        {
            JSonResult objResult = new JSonResult();
            string     response  = string.Empty;

            try
            {
                Session objSession = new Session()
                {
                    UserId = AutenticationManager.GetUser().IdUsuario,
                };

                List <MDonorPartner>           entList     = new List <MDonorPartner>();
                List <ModelDonorPartnerResult> entListData = new List <ModelDonorPartnerResult>();
                entListData = (List <ModelDonorPartnerResult>)Session["ListDonors"];

                foreach (ModelDonorPartnerResult item in entListData)
                {
                    MDonorPartner mDonorPartner = new MDonorPartner();
                    mDonorPartner.DonorCode      = item.DonorCode;
                    mDonorPartner.DonorName      = item.DonorName;
                    mDonorPartner.FundingPartner = item.FundingPartner;
                    entList.Add(mDonorPartner);
                }

                response = new WebApiDonorPartner().InsertDonorPartner(entList, objSession);

                string statusCode    = response.Split('|')[0];
                string statusMessage = response.Split('|')[1];

                objResult.isError = statusCode.Equals("2");
                objResult.message = statusCode.Equals("2") ? statusMessage : string.Format(MessageResource.SaveSuccess, "Donors");;
            }
            catch (Exception ex)
            {
                objResult.message = string.Format(MessageResource.SaveError + "Error :" + ex.Message, "Donors");
            }
            return(Json(objResult));
        }
Esempio n. 6
0
        public ActionResult Register(LoadFundsViewModel model, HttpPostedFileBase imageFile)
        {
            JSonResult objResult = new JSonResult();
            string     response  = string.Empty;

            try
            {
                Session objSession = new Session()
                {
                    UserId = AutenticationManager.GetUser().IdUsuario,
                };

                List <MFund>           entList     = new List <MFund>();
                List <ModelFundResult> entListData = new List <ModelFundResult>();
                entListData = (List <ModelFundResult>)Session["ListFunds"];

                foreach (ModelFundResult item in entListData)
                {
                    MFund mFund = new MFund();
                    mFund.FundCode    = item.FundCode;
                    mFund.Description = item.Description;
                    entList.Add(mFund);
                }

                response = new WebApiFund().InsertFund(entList, objSession);

                string statusCode    = response.Split('|')[0];
                string statusMessage = response.Split('|')[1];

                objResult.isError = statusCode.Equals("2");
                objResult.message = string.Format(MessageResource.SaveSuccess, "Funds");;
            }
            catch (Exception ex)
            {
                objResult.message = string.Format(MessageResource.SaveError + "Error :" + ex.Message, "Funds");
            }
            return(Json(objResult));
        }
Esempio n. 7
0
        public ActionResult Login(LoginViewModel model)
        {
            MUser eUser       = new MUser();
            MUser eUserReturn = new MUser();

            eUser.User     = model.User;
            eUser.Password = model.Password;

            eUserReturn = new WebApiUser().LoginUser(eUser);

            if (eUserReturn == null || string.IsNullOrEmpty(eUserReturn.User))
            {
                ModelState.AddModelError("", "Invalid username or password");
                return(View(model));
            }
            else
            {
                if (eUserReturn.Status.Equals(0))
                {
                    ModelState.AddModelError("", "Inactive user");
                    return(View(model));
                }
                else
                {
                    objUserIdenty = new UserIdentity();

                    objUserIdenty.Nombres   = eUserReturn.Name;
                    objUserIdenty.IdUsuario = eUserReturn.UserId;
                    objUserIdenty.Usuario   = eUserReturn.User;
                    objUserIdenty.Token     = eUserReturn.Token;
                    AutenticationManager.SaveLogin(objUserIdenty);

                    return(RedirectToAction("Index", "Home"));
                }
            }
        }
Esempio n. 8
0
        public ActionResult GetMenu(string id, PerfilViewModel model)
        {
            PanelViewModel  modelObj  = new PanelViewModel();
            List <MOptions> lstResult = null;
            List <MOptions> lstQuery;
            string          strController = string.Empty;
            MOptions        entOpciones   = new MOptions();
            UserIdentity    objUserIdenty = AutenticationManager.GetUser();

            Session objSession = new Session()
            {
                UserId = AutenticationManager.GetUser().IdUsuario,
            };

            entOpciones.ProfileId = Convert.ToInt32(id);
            lstResult             = new WebApiOptions().GetOptions(entOpciones, objSession);

            AutenticationManager.SetOpciones(lstResult);
            AutenticationManager.SetPerfil(Convert.ToInt32(id));

            modelObj.PerfilId = id;

            lstQuery = lstResult.Where(x => x.Action == 1).ToList();

            modelObj.Items = new List <PanelTab>();

            foreach (var item in lstQuery)
            {
                PanelTab pnlTab = new PanelTab();
                pnlTab.Items = new List <PanelTabItem>();

                pnlTab.Id   = "p" + item.OptionId.ToString();
                pnlTab.Text = item.Title;

                var lstN2 = lstResult.Where(a => a.Action == 2 && a.IdFather == item.OptionId);
                foreach (var itemN2 in lstN2)
                {
                    PanelTabItem pnlTabItem = new PanelTabItem()
                    {
                        Id          = itemN2.OptionId.ToString(),
                        Text        = itemN2.Title,
                        IsSeparator = true
                    };

                    pnlTab.Items.Add(pnlTabItem);

                    var lstN3 = lstResult.Where(a => a.Action == 3 && a.IdFather == itemN2.OptionId);
                    foreach (var itemN3 in lstN3)
                    {
                        pnlTab.Items.Add(new PanelTabItem()
                        {
                            Id     = itemN3.OptionId.ToString(),
                            Text   = itemN3.Title,
                            Action = string.IsNullOrEmpty(itemN3.Link) ? "" : itemN3.Link
                        });
                    }
                }

                modelObj.Items.Add(pnlTab);
            }

            return(PartialView("_TabMenu", modelObj));
        }
Esempio n. 9
0
        public ActionResult New()
        {
            //BE.EPerfiles objResult;
            ViewBag.Title   = "Register Profile";
            ViewBag.Confirm = string.Format(MessageResource.SaveConfirm, "Profile");

            ProfileViewModel ViewProfile = new ProfileViewModel();

            try
            {
                BE.Session objSession = new BE.Session()
                {
                    UserId = AutenticationManager.GetUser().IdUsuario,
                };

                ViewBag.Estado = Extension.GetStatus().Select(x => new SelectListItem
                {
                    Value = x.Id,
                    Text  = x.Value
                });

                List <ResulOptionProfileViewModel> ListOptionProfile = new List <ResulOptionProfileViewModel>();

                ViewProfile.ProfileId = 0;
                ViewProfile.Profile   = "";
                ViewProfile.Status    = "1";

                List <BE.MOptions> options = new List <BE.MOptions>();
                BE.MOptions        option  = new BE.MOptions();
                option.ProfileId = 0;

                options = new WebApiOptions().GetOptionsByProfile(option, objSession);

                ResulOptionProfileViewModel oOptionProfile = new ResulOptionProfileViewModel();

                foreach (BE.MOptions item in options)
                {
                    oOptionProfile                = new ResulOptionProfileViewModel();
                    oOptionProfile.ProfileId      = item.ProfileId;
                    oOptionProfile.OptionId       = item.OptionId;
                    oOptionProfile.FlagActive     = item.FlagActive;
                    oOptionProfile.Title          = item.Title;
                    oOptionProfile.TitleSubModule = item.TitleSubModule;
                    oOptionProfile.TitleModule    = item.TitleModule;

                    if (item.FlagActive.ToString().Equals("1"))
                    {
                        oOptionProfile.FlagCheck = "true";
                    }
                    else
                    {
                        oOptionProfile.FlagCheck = "false";
                    }

                    ListOptionProfile.Add(oOptionProfile);
                }

                ViewProfile.Result = ListOptionProfile;
            }
            catch (Exception)
            {
                ModelState.AddModelError("viewError", MessageResource.PartialViewLoadError);
                return(View("_ErrorView"));
            }
            return(PartialView("Register", ViewProfile));
        }