private AssessmentModels InitModel(int documentId) { AssessmentModels models = new AssessmentModels(); models.DocumentId = documentId; models.BODescription = new List <string>(); models.BOEmployeeScore = new List <string>(); models.BOGoals = new List <string>(); models.BOWeight = new List <int>(); models.GBDemonstatedBehavior = new List <string>(); models.GBExpectedBehavior = new List <string>(); models.GBEmployeeScore = new List <string>(); if (documentId == 0) { for (int i = 0; i <= 4; i++) { models.BODescription.Add(string.Empty); models.BOEmployeeScore.Add(string.Empty); models.BOGoals.Add(string.Empty); models.BOWeight.Add(0); if (i < 4) { models.GBDemonstatedBehavior.Add(string.Empty); models.GBExpectedBehavior.Add(string.Empty); models.GBEmployeeScore.Add(string.Empty); } } } return(models); }
public IActionResult SaveFormAssessment(AssessmentModels model) { AssessmentRepository repo = new AssessmentRepository(); try { model.EmployeeId = Convert.ToInt32(ViewBag.employeeId); repo.CreateAssessment(model); return(RedirectToAction("Index")); } catch (Exception e) { return(RedirectToAction("IndividualAssessment", model)); } }
public IActionResult IndividualAssessment(AssessmentModels model = null) { string ESMJson = HttpContext.Session.GetString("ESM"); EmployeeSessionModel ESM = JsonConvert.DeserializeObject <EmployeeSessionModel>(ESMJson); if (!string.IsNullOrEmpty(ESM.EmployeeId)) { if (model.DocumentId != 0) { model = this.InitModel(model.DocumentId); model.BODescription = new List <string>(); AssessmentRepository assesmentRepo = new AssessmentRepository(); Performanceappraisal assessment = assesmentRepo.GetPerfAppById(model.DocumentId); foreach (var item in assessment.Businessobjective) { model.BODescription.Add(item.Description); model.BOEmployeeScore.Add(item.Employeescore); model.BOGoals.Add(item.Goalachievement); model.BOWeight.Add(item.Weight); } foreach (var item in assessment.Globalbehavior) { model.GBDemonstatedBehavior.Add(item.Demonstratedbehavior); model.GBEmployeeScore.Add(item.Employeescore); model.GBExpectedBehavior.Add(item.Expectedbehavior); } model.BODescriptiveScore = assessment.Bodescriptivescore; model.BONumericalScore = assessment.Bonumericscore; model.GBNumericalScore = assessment.Gbnumericscore; model.GBDescriptiveScore = assessment.Gbdescriptivescore; model.CareerAspirationComment = assessment.Careeraspirationcomment; foreach (var item in assessment.Developmentplan) { model.DPDevelopmentArea = item.Developmentarea; model.DPMethods = item.Methods; model.DPPlan = item.Plan; model.DPStrengthArea = item.Strengtharea; } model.EmployeeComment = assessment.Employeecomment; model.ManagerComment = assessment.Managercomment; model.MobilityStatusId = (int)assessment.MobilityId; model.MobilityStatusDesc = assessment.Mobilitydesc; model.OverallDescriptiveScore = assessment.Overalldescriptivescore; model.OverallNumericalScore = assessment.Overallnumericscore; model.SecondLevelManagerComment = assessment._2ndlvlmanagercomment; model.ESM = ESM; } else { model = this.InitModel(0); model.ESM = ESM; } } else { model = this.InitModel(0); model.ESM = ESM; } DepartmentRepository deptRepo = new DepartmentRepository(); SubDeparmentRepository subDeptRepo = new SubDeparmentRepository(); ViewBag.departmentId = ESM.DepartmentId; ViewBag.subdepartmentId = ESM.SubDeparmentId; ViewBag.Department = deptRepo.GetDepartments(); ViewBag.SubDepartment = subDeptRepo.GetSubdepartments(); return(View(model)); }
public Performanceappraisal CreateAssessment(AssessmentModels model) { Employee employee = _context.Employee.FirstOrDefault(x => x.Id == model.EmployeeId); Mobilitycode mobility = new Mobilitycode(); Performanceappraisal perfApp = new Performanceappraisal(); perfApp.Bodescriptivescore = model.BODescriptiveScore; perfApp.Bonumericscore = model.BONumericalScore; perfApp.Careeraspirationcomment = model.CareerAspirationComment; perfApp.Createdate = DateTime.Now; perfApp.Employee = employee; perfApp.Employeeid = model.EmployeeId; perfApp.Employeecomment = model.EmployeeComment; perfApp.Gbdescriptivescore = model.GBDescriptiveScore; perfApp.Gbnumericscore = model.GBNumericalScore; perfApp.Managercomment = model.ManagerComment; if (model.submit) { Statuscode status = _context.Statuscode.FirstOrDefault(x => x.Description == "SUBMITTED"); if (status != null) { perfApp.Status = status; perfApp.Statusid = status.Id; } else { status = _context.Statuscode.FirstOrDefault(x => x.Description == "PROGRESS"); perfApp.Status = status; perfApp.Statusid = status.Id; } } else { Statuscode status = _context.Statuscode.FirstOrDefault(x => x.Description == "PROGRESS"); perfApp.Status = status; perfApp.Statusid = status.Id; } if (!string.IsNullOrEmpty(model.MobilityStatusDesc)) { mobility = _context.Mobilitycode.FirstOrDefault(x => x.Id == 2); perfApp.Mobility = mobility; perfApp.MobilityId = 2; perfApp.Mobilitydesc = model.MobilityStatusDesc; } else { perfApp.MobilityId = model.MobilityStatusId; } perfApp.Overalldescriptivescore = model.OverallDescriptiveScore; perfApp.Overallnumericscore = model.OverallNumericalScore; perfApp.Statusid = 1; // 1.Progress 2.Submitted 3.Process 4.Finish perfApp._2ndlvlmanagercomment = model.SecondLevelManagerComment; //_context.Performanceappraisal.Add(perfApp); //this.SaveChange(); List <Businessobjective> BOList = new List <Businessobjective>(); for (int i = 0; i < model.BODescription.Count; i++) { Businessobjective bo = new Businessobjective(); bo.Description = model.BODescription.ElementAt(i); bo.Employeescore = string.IsNullOrEmpty(model.BOEmployeeScore.ElementAt(i).ToString()) ? null : model.BOEmployeeScore.ElementAt(i); bo.Goalachievement = string.IsNullOrEmpty(model.BOGoals.ElementAt(i)) ? null : model.BOGoals.ElementAt(i); bo.Weight = string.IsNullOrEmpty(model.BOWeight.ElementAt(i).ToString()) ? 0 : model.BOWeight.ElementAt(i); //bo.Performanceappraisalid = perfApp.Id; if (perfApp.Status.Description == "PROCESS") { bo.Managerscore = string.IsNullOrEmpty(model.BOManagerScore.ElementAt(i)) ? null : model.BOManagerScore.ElementAt(i); } bo.Performanceappraisal = perfApp; BOList.Add(bo); perfApp.Businessobjective.Add(bo); } //_context.Businessobjective.AddRange(BOList); //this.SaveChange(); List <Globalbehavior> GBList = new List <Globalbehavior>(); for (int i = 0; i < model.GBExpectedBehavior.Count; i++) { Globalbehavior gb = new Globalbehavior(); gb.Createdate = DateTime.Now; gb.Demonstratedbehavior = string.IsNullOrEmpty(model.GBDemonstatedBehavior.ElementAt(i)) ? "" : model.GBDemonstatedBehavior.ElementAt(i); gb.Employeescore = string.IsNullOrEmpty(model.GBEmployeeScore.ElementAt(i).ToString()) ? null : model.GBEmployeeScore.ElementAt(i); gb.Expectedbehavior = string.IsNullOrEmpty(model.GBExpectedBehavior.ElementAt(i)) ? "" : model.GBExpectedBehavior.ElementAt(i); if (perfApp.Status.Description == "PROCESS") { gb.Managerscore = string.IsNullOrEmpty(model.GBManagerScore.ElementAt(i).ToString()) ? null : model.GBManagerScore.ElementAt(i); } gb.Performanceappraisal = perfApp; //gb.Performanceappraisalid = perfApp.Id; GBList.Add(gb); perfApp.Globalbehavior.Add(gb); } //_context.Globalbehavior.AddRange(GBList); //this.SaveChange(); Developmentplan DP = new Developmentplan(); DP.Performanceappraisalid = perfApp.Id; DP.Createdate = DateTime.Now; DP.Developmentarea = model.DPDevelopmentArea; DP.Methods = model.DPMethods; DP.Performanceappraisal = perfApp; DP.Plan = model.DPPlan; DP.Strengtharea = model.DPStrengthArea; perfApp.Developmentplan.Add(DP); //_context.Developmentplan.Add(DP); //this.SaveChange(); _context.Performanceappraisal.Add(perfApp); this.SaveChange(); return(perfApp); }