public async Task <IActionResult> Create(CreateEvaluationViewModel viewModel) { if (ModelState.IsValid) { var currentUser = _userManager.FindByEmailAsync(User.Identity.Name).Result; var evaluation = new Evaluation(viewModel.SelectedEvaluationTypeId, viewModel.SelectedTechniqueId, currentUser.Id, viewModel.SelectedStudentId); _context.Add(evaluation); await _context.SaveChangesAsync(); var evaluationCriteria = _context.EvaluationCriterias.ToList(); evaluation.InitializeEvaluationStepEntries(evaluationCriteria); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Edit), new { id = evaluation.Id })); } var users = _userManager.GetUsersInRoleAsync("Student").Result; viewModel.TechniqueSelectList = new SelectList(_context.Techniques.OrderBy(x => x.Description).ToList(), "Id", "Description"); viewModel.EvaluationTypesSelectList = new SelectList(_context.EvaluationTypes.OrderBy(x => x.Description).ToList(), "Id", "Description"); viewModel.UsersSelectList = new SelectList(users.OrderBy(x => x.UserName), "Id", "UserName"); return(View(viewModel)); }
public async Task <IActionResult> Create(CreateEvaluationViewModel model) { if (!this.ModelState.IsValid) { return(this.View(model)); } var isEvaluated = this.evaluationService.ChekEvalInYear(model.Year, model.EmployeeId); if (isEvaluated) { this.ModelState.AddModelError(string.Empty, $"Evaluation for {model.Year} alredy exist. If you want to change it, view all Evaluations and click Edit button."); var employee = this.employeService.GetById <EmployeeSelectList>(model.EmployeeId); model.Name = employee.Name; var years = this.yearsForEval.GetYearsForEval(); model.Years = years; return(this.View(model)); } await this.evaluationService.CreateAsync(model); return(this.RedirectToAction("Index")); }
public async Task <IActionResult> Create(string employeeId = null) { var model = new CreateEvaluationViewModel(); var years = this.yearsForEval.GetYearsForEval(); if (employeeId != null) { var employee = this.employeService.GetById <EmployeeSelectList>(employeeId); if (employee == null) { return(this.NotFound()); } model.EmployeeId = employee.Id; model.Name = employee.Name; } else { var user = await this.userManager.GetUserAsync(this.User); var companyId = this.departmentService.GetCompanyIdByDepartmentId(user.DepartmentId); model.Employees = this.employeService.GetAllEmployees <EmployeeSelectList>(companyId); } model.Years = years; return(this.View(model)); }
public ActionResult AddEvaluation(Guid courseId) { var createModel = new CreateEvaluationViewModel(courseId); GetWeightedOptions(createModel); return(View(createModel)); }
protected CreateEvaluationDomainModel ConvertToDomainModel(CreateEvaluationViewModel viewModel) { return(new CreateEvaluationDomainModel { CourseId = viewModel.CourseId, Name = viewModel.Name, Weight = viewModel.Weight / 100, NumberOfScores = viewModel.NumberOfScores, PointsPerScore = viewModel.PointValuePerScore, DropLowest = viewModel.DropLowest }); }
// GET: Evaluations/Create public IActionResult Create() { var users = _userManager.GetUsersInRoleAsync("Student").Result; var viewModel = new CreateEvaluationViewModel() { TechniqueSelectList = new SelectList(_context.Techniques.OrderBy(x => x.Description).ToList(), "Id", "Description"), EvaluationTypesSelectList = new SelectList(_context.EvaluationTypes.OrderBy(x => x.Description).ToList(), "Id", "Description"), UsersSelectList = new SelectList(users.OrderBy(x => x.UserName), "Id", "UserName") }; return(View(viewModel)); }
private void GetWeightedOptions(CreateEvaluationViewModel createModel) { var weightedModel = Courses.GetCourseWeightType(createModel.CourseId); if (weightedModel.IsWeighted) { createModel.WeightedOnly = true; } if (weightedModel.IsStraightPoints) { createModel.StraightPointsOnly = true; } }
public async Task CreateAsync(CreateEvaluationViewModel model) { var eval = new Evaluations { Value = model.Value, Notes = model.Notes, CreatedOn = DateTime.UtcNow, EvaluationYear = model.Year, IsDeleted = false, UserId = model.EmployeeId }; await this.evaluationRepository.AddAsync(eval); await this.evaluationRepository.SaveChangesAsync(); }
public IActionResult Create(string employeeId) { var model = new CreateEvaluationViewModel(); var years = this.yearsForEval.GetYearsForEval(); var employee = this.employeeService.GetById <EmployeeSelectList>(employeeId); if (employee == null) { return(this.NotFound()); } model.EmployeeId = employee.Id; model.Name = employee.Name; model.Years = years; return(View("/Areas/Administration/Views/Evaluations/Create.cshtml", model)); }
public ActionResult Create(CreateEvaluationViewModel viewModel) { if (ModelState.IsValid) { var createDomainModel = ConvertToDomainModel(viewModel); var newDomainModel = Evaluations.CreateNewEvaluation(createDomainModel); if (newDomainModel.GetType() == typeof(EvaluationDomainModel)) { Courses.EvaluationModified(viewModel.CourseId); return(Complete((EvaluationDomainModel)newDomainModel)); } else { return(GradeTrackerError(newDomainModel, viewModel)); } } else { return(View("AddEvaluation", viewModel)); } }