public override List <HistoricalEvaluationDto> ExecuteWithResult() { IQueryable <EmployeeEvaluationHistory_Search.Projection> query = RavenSession .Query <EmployeeEvaluationHistory_Search.Projection, EmployeeEvaluationHistory_Search>() .Where(e => e.UserName == _userName); var employeesProjection = query.ToList() .Where(x => x.Period != null && 0 >= string.Compare(x.Period, _lastPeriod)) .OrderByDescending(x => x.Period) .ToList(); var mapper = new EmployeeEvaluationHelper(RavenSession, _userName); return(employeesProjection.Select(e => new HistoricalEvaluationDto() { AverageCalification = e.Califications, ResponsibleId = e.ResponsibleId, FullName = e.FullName, UserName = e.UserName, Period = e.Period, Evaluators = e.Evaluators != null ? e.Evaluators.ToList() : new List <string>(), State = EvaluationStateHelper.GetEvaluationState(e.AutoEvaluationDone, e.ResponsibleEvaluationDone, e.CompanyEvaluationDone, e.OpenToDevolution, e.Finished), Id = e.Id, }).ToList()); }
public ActionResult Calification(string period, string username, string sharedCode = null) { //1. If user is self //1.a. Check if it needs to be evaluated (if not, redirect or error) //1.b. If auto-evaluation is not done, show auto-evaluation to complete //1.c. If auto-evaluation is done, show auto-evaluation (no edit) //1.d. If auto-evaluation is done and company is done, show both //2. If not self //2.a. Check if it's responsible or evaluator of the user //2.a.1. If not, redirect or error //2.a.2. If it is, show the next point with the rest of evaluations //2.b. Evaluator/Responsible with no evaluation done, show standard evaluation to complete //2.c. Evaluator with evaluation done, show evaluation done //2.d. Responsible with evaluation done, show company evaluation to complete //2.e. Responsible with company evaluation done, show every evaluation including auto var loggedUser = DetectUser(); RavenQueryStatistics stats; EmployeeToEvaluate_Search.Projection evaluation = RavenSession .Query <EmployeeToEvaluate_Search.Projection, EmployeeToEvaluate_Search>() .Statistics(out stats) .Where(e => e.UserName == username && e.Period == period).FirstOrDefault(); // The evaluation doesn't exist if (evaluation == null) { return(HttpNotFound()); } var evaluationHelper = new EmployeeEvaluationHelper(RavenSession, loggedUser); var isNewerResponsible = string.Compare(evaluationHelper.GetLastPeriodForResponisble(username), period) > 0; var hasValidSharedCode = evaluation.SharedLinks != null? evaluation.SharedLinks.Any(x => x.SharedCode == sharedCode && x.ExpirationDate >= DateTime.UtcNow) : false; var isManager = IsEmployeeManager(loggedUser); var isLoggedUserEvaluator = IsEvaluator(loggedUser, username, evaluation.ResponsibleId, evaluation.Evaluators); var isLoggedUserEvaluated = loggedUser == username; if (!isLoggedUserEvaluated && !isLoggedUserEvaluator && !isManager && !hasValidSharedCode && !isNewerResponsible) { return(new HttpStatusCodeResult(403, "Access Denied")); } ViewBag.IsUserEvaluator = isLoggedUserEvaluator; ViewBag.Period = period; ViewBag.UserName = username; ViewBag.IsCalification = true; if (sharedCode != null) { ViewBag.SharedCode = sharedCode; } return(View("Calification")); }
public JsonNetResult GetEmployeeEvaluationHistory(string username) { var loggedUser = DetectUser(); var employeeEvaluationHelper = new EmployeeEvaluationHelper(RavenSession, loggedUser); var responsibleOfEvaluationPeriod = employeeEvaluationHelper.GetLastPeriodForResponisble(username); if (responsibleOfEvaluationPeriod == null) { throw new ApplicationException($"Not responsible of {username}'s evaluation in any period"); } var evaluationHistory = ExecuteCommand(new GetEmployeeEvaluationHistoryCommand(responsibleOfEvaluationPeriod, username)); return(Json(evaluationHistory)); }
public override List <EmployeeEvaluationDTO> ExecuteWithResult() { IRavenQueryable <EmployeeToEvaluate_Search.Projection> query = RavenSession .Query <EmployeeToEvaluate_Search.Projection, EmployeeToEvaluate_Search>(); if (Period != null) { query = query.Where(e => e.Period == Period); } var employeesProjection = query.ToList(); var mapper = new EmployeeEvaluationHelper(RavenSession, null); return(mapper.MapEmployeeEvaluation(employeesProjection)); }
public override List <EmployeeEvaluationDTO> ExecuteWithResult() { RavenQueryStatistics stats; IQueryable <EmployeeToEvaluate_Search.Projection> query = RavenSession .Query <EmployeeToEvaluate_Search.Projection, EmployeeToEvaluate_Search>() .Statistics(out stats) .Where(e => (e.Period == _period) && (e.UserName == _loggedUser || e.ResponsibleId == _loggedUser || e.Evaluators.Any(ev => ev == _loggedUser))); var employeesProjection = query.ToList(); var mapper = new EmployeeEvaluationHelper(RavenSession, _loggedUser); return(mapper.MapEmployeeEvaluation(employeesProjection)); }
public ActionResult HistoryDashboard(string username) { var loggedUser = DetectUser(); var employeeEvaluationHelper = new EmployeeEvaluationHelper(RavenSession, loggedUser); var lastResponiblePeriod = employeeEvaluationHelper.GetLastPeriodForResponisble(username); if (lastResponiblePeriod == null) { return(new HttpStatusCodeResult(403, "Access Denied")); } ScriptManager.RegisterGlobalJavascript( "ViewData", new { userName = username }, 500); return(View()); }
public override CalificationsDto ExecuteWithResult() { var evId = EmployeeEvaluation.GenerateEvaluationId(_period, _evaluatedUser); var evaluation = RavenSession.Load <EmployeeEvaluation>(evId); var evaluationHelper = new EmployeeEvaluationHelper(RavenSession, _loggedUser); if (evaluation == null) { throw new ApplicationException(string.Format("Error: EvaluaciĆ³n inexistente: {0}.", evId)); } var isVisitor = (evaluation.SharedLinks == null ? false : evaluation.SharedLinks.Any(x => x.SharedCode == _sharedCode && x.ExpirationDate > DateTime.UtcNow)) || //has SharedCode (string.Compare(evaluationHelper.GetLastPeriodForResponisble(_evaluatedUser), _period) > 0); //is newer Responsible Employee_Search.Projection employee = RavenSession .Query <Employee_Search.Projection, Employee_Search>() .Where(x => x.IsActive && x.UserName == evaluation.UserName).FirstOrDefault(); var califications = RavenSession.Advanced.LoadStartingWith <EvaluationCalification>(evId + "/").ToList(); var evaluators = califications.Where(c => c.Owner == CalificationType.Evaluator).Select(c => c.EvaluatorEmployee).ToList(); var autoEvaluationDone = califications.Any(c => c.Owner == CalificationType.Auto && c.Finished); var responsibleEvaluationDone = califications.Any(c => c.Owner == CalificationType.Responsible && c.Finished); var companyEvaluationDone = califications.Any(c => c.Owner == CalificationType.Company && c.Finished); var state = EvaluationStateHelper.GetEvaluationState(autoEvaluationDone, responsibleEvaluationDone, companyEvaluationDone, evaluation.ReadyForDevolution, evaluation.Finished); var evaluationDto = CalificationsEvaluationDto.Create(evaluation, evaluators, evaluation.CurrentPosition ?? employee.CurrentPosition, evaluation.Seniority ?? employee.Seniority, companyEvaluationDone, state); if (!CanViewEvaluation(evaluationDto, califications, isVisitor)) { throw new ApplicationException(string.Format("Error: Usuario {0} no tiene permiso para ver la evaluaciĆ³n {1}", _loggedUser, evId)); } // If evaluation is finished // - Show ALWAYS company & auto if (evaluation.Finished) { return(GetFinishedEvaluation(evaluationDto, califications)); } // If loggedUser is the evaluated // - Show auto-eval if not RFD // - Show auto-eval & company if RFD if (_loggedUser == _evaluatedUser) { return(GetAutoEvaluation(evaluationDto, califications)); } // If loggedUser is responsible // - Show all if (_loggedUser == evaluationDto.ResponsibleId) { return(GetFullEvaluation(evaluationDto, califications)); } // If loggedUser is evaluator // - Show evluator eval return(GetEvaluatorEvaluation(evaluationDto, califications)); }