Пример #1
0
        public PartialViewResult ShowLeftContent(CYCARoleType type)
        {
            object viewModel;
            CYCA_CareWorkerViewModel    model = new CYCA_CareWorkerViewModel();
            CYCA_CenterManagerViewModel modelCenterManager = new CYCA_CenterManagerViewModel();
            CYCA_TeamLeaderViewModel    modelTeamLeader    = new CYCA_TeamLeaderViewModel();

            switch (type)
            {
            case CYCARoleType.FacilityManager:
                modelCenterManager = GetCenterManagerChildren();
                modelCenterManager.TransferCount = modelCenterManager.childrenTransferByMe.Count() + modelCenterManager.childrenTransferToMe.Count();
                viewModel = modelCenterManager;
                return(PartialView("~/Views/Home/_CenterManagerLeft.cshtml", viewModel));

            case CYCARoleType.TeamLeader:
                modelTeamLeader = GetTeamLeaderChildren();
                modelTeamLeader.TransferCount = modelTeamLeader.childrenTransferByMe.Count() + modelTeamLeader.childrenTransferToMe.Count();
                viewModel = modelTeamLeader;
                return(PartialView("~/Views/Home/_TeamLeaderLeft.cshtml", viewModel));

            case CYCARoleType.ProvincialCoordinator:
                //modelCenterManager = GetCenterManagerChildren();
                //modelCenterManager.TransferCount = modelCenterManager.childrenTransferByMe.Count() + modelCenterManager.childrenTransferToMe.Count();
                viewModel = modelCenterManager;
                return(PartialView("~/Views/Home/_ProvincialCoordinatorLeft.cshtml", viewModel));

            case CYCARoleType.CareWorker:
            default:
                model = GetCareWorkerChildren();
                model.TransferCount = model.childrenTransferByMe.Count() + model.childrenTransferToMe.Count();
                viewModel           = model;
                return(PartialView("~/Views/Home/_CareWorkerLeft.cshtml", viewModel));
            }
        }
Пример #2
0
        public PartialViewResult ShowRightContent(CYCARoleType type)
        {
            var currentUser = (User)Session["CurrentUser"];
            var userId      = -1;


            if (currentUser != null)
            {
                userId = currentUser.User_Id;
            }
            object viewModel;

            switch (type)
            {
            case CYCARoleType.FacilityManager:
                CYCA_CenterManagerRightViewModel returnModel = new CYCA_CenterManagerRightViewModel();
                //returnModel = GetTeamLeadersAndChildren();
                //returnModel = GetCenterManagerRightView();
                returnModel = GetCenterManagerRightViewUpdated();
                viewModel   = returnModel;
                return(PartialView("~/Views/Home/_CenterManagerRight.cshtml", viewModel));

            case CYCARoleType.TeamLeader:
                CYCA_TeamLeaderRightViewModel returnModelTeamLeader = new CYCA_TeamLeaderRightViewModel();
                returnModelTeamLeader = GetCareWorkersAndChildren();;
                viewModel             = returnModelTeamLeader;
                return(PartialView("~/Views/Home/_TeamLeaderRight.cshtml", viewModel));

            case CYCARoleType.ProvincialCoordinator:
                CYCABedSpaceRequestViewModel returnModelProv = new CYCABedSpaceRequestViewModel();
                var StatList = bedSpaceModel.GetBedStats();
                ViewBag.RequestStatusList = new SelectList(StatList, "Request_Status_Id", "Description");

                var request_Outcomes = bedSpaceModel.GetBedSpaceRequestOutcome();
                ViewBag.RequestOutcomeList = new SelectList(request_Outcomes, "Outcome_Id", "Description");

                return(PartialView("~/Views/Home/_ProvincialCoordinatorRight.cshtml"));

            case CYCARoleType.CareWorker:
            default:
                var venue_list = venues.GetAplCycaVenues();
                ViewBag.VenueList = new SelectList(venue_list, "Venue_Id", "VenueName");
                var userList = userModel.GetUserListById(userId);
                ViewBag.UsersList = new SelectList(userList, "User_Id", "fullname");
                return(PartialView("~/Views/Home/_CareWorkerRight.cshtml"));
            }
        }
Пример #3
0
        public ActionResult Index()
        {
            //return RedirectToAction("Index", "Intake");
            var    currentUser  = new User();
            string facilityname = "";



            if ((Session["CurrentUser"] == null) && (Request.Cookies[FormsAuthentication.FormsCookieName] != null))
            {
                var authUser = FormsAuthentication.Decrypt(Request.Cookies[FormsAuthentication.FormsCookieName].Value).Name;
                currentUser           = userModel.GetSpecificUser(authUser);
                ViewBag.CurrentUserId = currentUser.User_Id;
                var res = db.apl_User_Image.Where(ur => ur.User_Id == currentUser.User_Id).Select(us => us.Image_Content).SingleOrDefault();
                if (res.Length > 0)
                {
                    ViewBag.CurrentUserImage = Convert.ToBase64String(res);
                }
                Session.Remove("CurrentUser");
                Session.Remove("MenuLayout");
                Session.Add("CurrentUser", currentUser);
            }
            else
            {
                if (Session["CurrentUser"] != null)
                {
                    var loggedInUser = (User)Session["CurrentUser"];

                    var userModel = new UserModel();
                    currentUser           = userModel.GetSpecificUser(loggedInUser.User_Id);
                    ViewBag.CurrentUserId = currentUser.User_Id;
                    var res = db.apl_User_Image.Where(ur => ur.User_Id == currentUser.User_Id).Select(us => us.Image_Content).SingleOrDefault();
                    if (res.Length > 0)
                    {
                        ViewBag.CurrentUserImage = Convert.ToBase64String(res);
                    }
                    facilityname = userModel.GetFacilityByUserId(loggedInUser.User_Id);
                }
            }
            var         authorizedRoles = new List <Role>();
            List <Role> myRoles         = new List <Role>();

            authorizedRoles = currentUser.Roles.Where(rr => rr.Description.Contains("CYCA")).ToList();
            CYCARoleType defaultRole     = CYCARoleType.Other;
            string       teamLeader      = ConfigurationManager.AppSettings["TeamLeaderRole"];
            string       facilityManager = ConfigurationManager.AppSettings["CenterManagerRole"];
            string       careWorker      = ConfigurationManager.AppSettings["CareWorkerRole"];
            bool         hasFacility     = false;
            bool         hasTeamLeader   = false;
            bool         hasCareWorker   = false;

            foreach (Role r in authorizedRoles)
            {
                if (r.Description.ToLower() == facilityManager.ToLower())
                {
                    myRoles.Add(new Role()
                    {
                        Description = "Center Manager",
                        Role_Id     = r.Role_Id
                    });
                    ViewBag.RoleId = r.Role_Id;
                    defaultRole    = CYCARoleType.FacilityManager;
                    hasFacility    = true;
                }
                else if (r.Description.ToLower() == teamLeader.ToLower())
                {
                    myRoles.Add(new Role()
                    {
                        Description = "Team Leader",
                        Role_Id     = r.Role_Id
                    });
                    if (!hasFacility)
                    {
                        ViewBag.RoleId = r.Role_Id;
                        defaultRole    = CYCARoleType.TeamLeader;
                        hasTeamLeader  = true;
                    }
                }
                else if (r.Description.ToLower() == careWorker.ToLower())
                {
                    myRoles.Add(new Role()
                    {
                        Description = "Care Worker",
                        Role_Id     = r.Role_Id
                    });
                    if (!hasFacility && !hasTeamLeader)
                    {
                        ViewBag.RoleId = r.Role_Id;
                        defaultRole    = CYCARoleType.CareWorker;
                        hasCareWorker  = true;
                    }
                }
                else
                {
                    myRoles.Add(new Role()
                    {
                        Description = r.Description,
                        Role_Id     = r.Role_Id
                    });
                    if (!hasFacility && !hasTeamLeader && !hasCareWorker)
                    {
                        ViewBag.RoleId = r.Role_Id;
                        defaultRole    = CYCARoleType.Other;
                    }
                }
            }
            ViewBag.Roles        = new SelectList(myRoles, "Role_Id", "Description", ViewBag.RoleId);
            ViewBag.DefaultRole  = defaultRole;
            ViewBag.FacilityName = facilityname;

            return(View());
        }