示例#1
0
        public IActionResult Index()
        {
            var userid = int.Parse(HttpContext.Session.GetString("UserId"));

            var model = new UserAccountViewModel();

            model.DashboardAccess = _Services.DashboardAccessPerUser(userid);
            model.UserCount       = _Services.UserCount();
            model.RaterCount      = _Services.RaterCount();
            model.ApproverCount   = _Services.ApproverCount();
            model.EmployeeCount   = _Services.EmployeeCount();
            model.AccountPeriod   = _Services.AccountPeriod();
            var recentaccounts = _Services.MostRecentAccounts()
                                 .Select(a => new RecentAccount
            {
                Id           = a.Id,
                Name         = a.FirstName + " " + a.LastName,
                CreationDate = a.CreationDate,
            }).ToList();

            model.RecentAccounts = recentaccounts;
            var recentemp = _Services.MostRecentEmployees()
                            .Select(a => new RecentEmployee
            {
                Id           = a.Id,
                Name         = a.FirstName + " " + a.LastName,
                CreationDate = a.CreationDate,
            }).ToList();

            model.RecentEmployees = recentemp;

            //rater
            model.AssignedRateeCount  = _Services.AssignedRateeCount(userid);
            model.EvaluatedRateeCount = _Services.EvaluatedRateeCount(userid);
            model.ApprovedRatingCount = _Services.ApprovedRatingCount(userid);
            model.PendingRatingCount  = _Services.PendingRatingCount(userid);
            model.Employees           = _Services.EmployeesPerRater(userid);

            //Approver
            model.AssignedPerApprover = _Services.AssignedPerApprover(userid);
            model.ApprovedEvaluation  = _Services.ApprovedEvaluation(userid);
            model.PendingEvaluation   = _Services.PendingForApproval(userid);
            model.UserPerApprovers    = _Services.ApproverAssignedUser(userid);

            var behavioralheaderitems = _Services.GetBehavioralEvaluations(userid);
            var kraheaderitems        = _Services.GetKRAEvaluations(userid);

            List <EvaluationLineItem> bitems = new List <EvaluationLineItem>();
            List <EvaluationLineItem> kitems = new List <EvaluationLineItem>();

            foreach (var item in behavioralheaderitems)
            {
                var x = _Services.GetBehavioralLineItems(item.Id);

                foreach (var aa in x)
                {
                    bitems.Add(aa);
                }
            }

            foreach (var item in kraheaderitems)
            {
                var x = _Services.GetKRAEvaluationLineItems(item.Id);
                foreach (var aa in x)
                {
                    kitems.Add(aa);
                }
            }

            model.BehavioralHeaderItems = behavioralheaderitems;
            model.KRAHeaderItems        = kraheaderitems;

            model.BehavioralLineItems = bitems;
            model.KRALineItems        = kitems;

            var id = int.Parse(HttpContext.Session.GetString("UserId"));

            model.IsAdmin    = _Services._IsAdmin(id);
            model.IsRater    = _Services._IsRater(id);
            model.IsApprover = _Services._IsApprover(id);
            model.IsEmployee = _Services._IsEmployee(id);
            return(View(model));
        }