public IActionResult EvaluateKeyResultArea(int id, int kraid)
        {
            var name = _Evaluation.EmployeeNameById(id);
            var kra  = _Evaluation.KeyResultAreaPerId(kraid);
            var ksi  = _Evaluation.GetKeySuccessIndicators(kraid)
                       .Select(a => new EvaluationSuccessIndicatorItem
            {
                Id          = a.Id,
                Description = a.Description,
                Title       = a.Title,
                Weight      = a.Weight,
                Comment     = string.Empty,
                Score       = 0,
                //RatingTableItems = _Evaluation.GetRatingTableItemsPerId(a.RatingTable.Id)
                //.Select(b => new EvaluationRatingTableItem
                //{
                //    Id = b.Id,
                //    Description = b.Description,
                //    Weight = b.Weight.ToString(),
                //}).ToList(),
            }).ToList();
            var model = new EmployeeSuccessAreaEvaluation
            {
                EmployeeId                  = id,
                Name                        = name,
                KeyResultAreaId             = kraid,
                Title                       = kra.Title,
                Description                 = kra.Description,
                Weight                      = kra.Weight.ToString(),
                EvaluationSuccessIndicators = ksi
            };

            return(View(model));
        }
        public IActionResult SubmitKeyResultArea(EmployeeSuccessAreaEvaluation model)
        {
            var UserId = int.Parse(HttpContext.Session.GetString("UserId"));

            if (ModelState.IsValid)
            {
                var header = new RatingHeader
                {
                    Type         = "kra",
                    CreatedBy    = _Evaluation.GetAccountById(UserId).Id.ToString(),
                    CreationDate = DateTime.Now,
                    Rater        = _Evaluation.GetAccountById(UserId),
                    Ratee        = _Evaluation.GetEmployeePerId(model.EmployeeId),
                    Status       = _Evaluation.GetStatusPerId(TransactionStatus.Save.ToInt()),
                };
                var items = new List <RatingKeySuccessArea>();
                foreach (var item in model.EvaluationSuccessIndicators)
                {
                    var rating = new RatingKeySuccessArea
                    {
                        KeyResultArea       = _Evaluation.GetKeyResultAreaById(model.KeyResultAreaId),
                        KeySuccessIndicator = _Evaluation.GetSuccessIndicatorById(item.Id),
                        Score   = item.Score,
                        Comment = item.Comment,
                    };
                    items.Add(rating);
                }
                var id = int.Parse(HttpContext.Session.GetString("UserId"));
                _Evaluation.SaveKeyResultAreaEvaluation(header, items, id, model.EmployeeId);
                return(RedirectToAction("EmployeeEvaluation", new { id = model.EmployeeId }));
            }
            else
            {
                return(RedirectToAction("EvaluateBehavioral", new { id = model.EmployeeId, kraid = model.KeyResultAreaId }));
            }
        }