public IActionResult Update(CreatePeerEvaluationViewModel model)
        {
            var userId = int.Parse(HttpContext.Session.GetString("UserId"));
            var header = new CriteriaEvaluationHeader
            {
                Id       = model.Header.RecordId,
                Criteria = _Services.CriteriaHeaderById(model.Header.Id),
                Rater    = _Services.GetAccountById(userId),
                Ratee    = _Services.GetAccountById(model.EmployeeId),
            };
            List <CriteriaEvaluationLine> items = new List <CriteriaEvaluationLine>();

            foreach (var item in model.LineItems)
            {
                var i = new CriteriaEvaluationLine
                {
                    Id           = item.RecordId,
                    CriteriaLine = _Services.CriteriaLineById(item.Id),
                    Comment      = item.Comment,
                    Score        = item.Score
                };
                items.Add(i);
            }
            _Services.Update(header, items, userId);
            return(RedirectToAction("Overview", new { employee = model.EmployeeId }));
        }
        public IActionResult Evaluate(int employeeid)
        {
            var userId = int.Parse(HttpContext.Session.GetString("UserId"));
            var item   = _Services.EmployeeCriteriaAssignmentByEmployeeId(employeeid);

            var header = new EvaluatePeerHeaderViewModel
            {
                Id          = item.Criteria.Id,
                Title       = item.Criteria.Title,
                Description = item.Criteria.Description,
                Weight      = item.Criteria.Weight,
            };
            var line = _Services.CriteriaLinesByHeaderId(item.Criteria.Id)
                       .Select(a => new EvaluatePeerLineViewModel
            {
                Id          = a.Id,
                Title       = a.Title,
                Description = a.Description,
                Weight      = Convert.ToInt32(a.Weight),
            }).ToList();
            var model = new CreatePeerEvaluationViewModel
            {
                EmployeeId = employeeid,
                Name       = _Services.GetName(employeeid),
                Header     = header,
                LineItems  = line,
            };

            return(View(model));
        }
        public IActionResult Edit(int employeeid)
        {
            var userId = int.Parse(HttpContext.Session.GetString("UserId"));
            var h      = _Services.CriteriaEvaluationPerEmployeeId(employeeid, userId);
            var header = new EvaluatePeerHeaderViewModel
            {
                RecordId    = h.Id,
                Id          = h.Criteria.Id,
                Title       = h.Criteria.Title,
                Description = h.Criteria.Description,
                Weight      = h.Criteria.Weight
            };
            var lineitems = _Services.EvaluationLinesByHeaderId(h.Id)
                            .Select(a => new EvaluatePeerLineViewModel
            {
                RecordId    = a.Id,
                Id          = a.CriteriaLine.Id,
                Title       = a.CriteriaLine.Title,
                Description = a.CriteriaLine.Description,
                Weight      = Convert.ToInt32(a.CriteriaLine.Weight),
                Comment     = a.Comment,
                Score       = Convert.ToInt32(a.Score),
            }).ToList();
            var model = new CreatePeerEvaluationViewModel
            {
                EmployeeId = employeeid,
                Name       = _Services.GetName(employeeid),
                Header     = header,
                LineItems  = lineitems,
            };

            return(View(model));
        }