public ActionResult AuditAppraisal(AppraisalModel model) { try { model.AuditUser = CurrentUser.Id; return(Json(new JsonMessage(service.AuditAppraisal(model)))); } catch (Exception e) { return(Json(new JsonMessage(false, e.Message))); } }
public IActionResult AppraisalDetails(int id) { ViewBag.employees = _dataContext.Employees.Select(item => new SelectListItem() { Text = item.EmployeeName, Value = item.EmployeeId + "", Selected = false }).ToList(); var appraisal = _dataContext.Appraisals.Find(id); AppraisalModel selectedAppraisal = new AppraisalModel(); selectedAppraisal.EmployeeId = appraisal.EmployeeId; selectedAppraisal.CurrentAppraisal = appraisal.CurrentAppraisal; selectedAppraisal.NextAppraisal = appraisal.NextAppraisal; selectedAppraisal.Files = appraisal.FilesName.Split(','); selectedAppraisal.Remark = appraisal.Remark; ViewBag.history = _dataContext.Appraisals.Where(x => x.EmployeeId == appraisal.EmployeeId).OrderByDescending(x => x.CurrentAppraisal).ToList(); return(View(selectedAppraisal)); }
public IActionResult Appraisals() { List <AppraisalModel> models = new List <AppraisalModel>(); foreach (var item in _dataContext.Appraisals.Join(_dataContext.Employees, a => a.EmployeeId, e => e.EmployeeId, (a, e) => new { Appraisal = a, Employee = e }).OrderByDescending(x => x.Appraisal.CurrentAppraisal)) { AppraisalModel appraisalModel = new AppraisalModel(); appraisalModel.AppraisalId = item.Appraisal.AppraisalId; appraisalModel.EmployeeId = item.Appraisal.EmployeeId; appraisalModel.EmployeeName = item.Employee.EmployeeName; appraisalModel.CurrentAppraisal = item.Appraisal.CurrentAppraisal; appraisalModel.NextAppraisal = item.Appraisal.NextAppraisal; appraisalModel.Remark = item.Appraisal.Remark; models.Add(appraisalModel); } return(View(models)); }
public IActionResult AddAppraisal(AppraisalModel model, List <IFormFile> files) { Appraisal appraisal = new Appraisal(); appraisal.EmployeeId = model.EmployeeId; appraisal.CurrentAppraisal = model.CurrentAppraisal; appraisal.NextAppraisal = model.NextAppraisal; appraisal.Remark = model.Remark; model.AllFiles = ""; foreach (var file in files) { if (file == null || file.Length == 0) { continue; } var path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/files", Path.GetFileName(file.FileName)); file.CopyToAsync(new FileStream(path, FileMode.Create)); model.AllFiles += Path.GetFileName(file.FileName); } appraisal.FilesName = model.AllFiles; _dataContext.Add(appraisal); _dataContext.SaveChanges(); return(RedirectToAction("Appraisals")); }
public ActionResult SubmitAppraisal(AppraisalModel model) { model.UpdateUser = CurrentUser.Id; return(Json(new JsonMessage(service.SaveAppraisal(model, true)))); }