// // GET: /Kpi/Create public ActionResult Create(int? cycle) { if (cycle != null) { int pf = this.empDir.GetEmployeePF(User.Identity.Name); #region Set the current cycle ViewBag.CurrentCycle = cycle; #endregion // // Get the other View bag details if (pf != -1) // ensure that that user is valid { #region Other view settings CycleRepository cycleRepo = new CycleRepository(); // // Load the view fields PF, fullname of user and the performance cycle ViewBag.Pf = this.empDir.GetEmployeePF(User.Identity.Name); ViewBag.Fullname = this.empDir.GetFullname(this.empDir.GetEmployeePF(User.Identity.Name)); ViewBag.CycleSelection = cycleRepo.GetCycleSelectionList(Int32.Parse(User.Identity.Name.Substring(8))); if (!string.IsNullOrEmpty(cycleRepo.GetSelectedCycle(Int32.Parse(User.Identity.Name.Substring(8)), cycle))) { ViewBag.Cycle = cycleRepo.GetSelectedCycle(Int32.Parse(User.Identity.Name.Substring(8)), cycle); } else if (!string.IsNullOrEmpty(cycleRepo.GetRunningCycle())) { ViewBag.Cycle = cycleRepo.GetRunningCycle(); } else { ViewBag.Cycle = cycleRepo.GetLatestCycle(); } // Setup the employee objective selection list. ViewBag.EmployeeObjectiveSelectList = this.objRepo.GetEmployeeObjectiveSelect(cycle, pf); #endregion // // Return the view with the model #region return view return View(); #endregion } else { // // Return error view #region Invalid user return View("Error"); #endregion } } else { // // Ensure that the performance cycle being process is provided. #region Cycle not provided ViewBag.Fullname = this.empDir.GetFullname(this.empDir.GetEmployeePF(User.Identity.Name)); return View("Error"); #endregion } }
// // GET: /PerformanceReport/ public ActionResult Index(int? cycle) { if (cycle != null) { CycleRepository cycleRepo = new CycleRepository(); List<CycleSelectList> cyclelist = new List<CycleSelectList>() { new CycleSelectList{Id= 1, PerformanceCycle= DateTime.Now.AddYears(1).Year+ " - Half I"}, new CycleSelectList{Id=2, PerformanceCycle=DateTime.Now.AddYears(1).Year+ " - Half II"}, new CycleSelectList{Id= 3, PerformanceCycle=DateTime.Now.Year.ToString()+ " - Half I"}, new CycleSelectList{Id=4, PerformanceCycle=DateTime.Now.Year.ToString()+ " - Half II"}, }; ViewBag.Pf = this.empDir.GetEmployeePF(User.Identity.Name); ViewBag.Fullname = this.empDir.GetFullname(this.empDir.GetEmployeePF(User.Identity.Name)); ViewBag.CycleList = cyclelist; ViewBag.CycleSelection = cycleRepo.GetCycleSelectionList(Int32.Parse(User.Identity.Name.Substring(8))); if (!string.IsNullOrEmpty(cycleRepo.GetSelectedCycle(Int32.Parse(User.Identity.Name.Substring(8)), cycle))) { ViewBag.Cycle = cycleRepo.GetSelectedCycle(Int32.Parse(User.Identity.Name.Substring(8)), cycle); } else if (!string.IsNullOrEmpty(cycleRepo.GetRunningCycle())) { ViewBag.Cycle = cycleRepo.GetRunningCycle(); } else { ViewBag.Cycle = cycleRepo.GetLatestCycle(); } } else { CycleRepository cycleRepo = new CycleRepository(); List<CycleSelectList> cyclelist = new List<CycleSelectList>() { new CycleSelectList{Id= 1, PerformanceCycle="2013 - Half I"}, new CycleSelectList{Id=2, PerformanceCycle="2013 - Half II"}, new CycleSelectList{Id= 3, PerformanceCycle="2014 - Half I"}, new CycleSelectList{Id=4, PerformanceCycle="2014 - Half II"}, }; ViewBag.Pf = this.empDir.GetEmployeePF(User.Identity.Name); ViewBag.Fullname = this.empDir.GetFullname(this.empDir.GetEmployeePF(User.Identity.Name)); ViewBag.CycleList = cyclelist; ViewBag.CycleSelection = cycleRepo.GetCycleSelectionList(Int32.Parse(User.Identity.Name.Substring(8))); if (!string.IsNullOrEmpty(cycleRepo.GetRunningCycle())) { ViewBag.Cycle = cycleRepo.GetRunningCycle(); } else { ViewBag.Cycle = cycleRepo.GetLatestCycle(); } } return View(); }
public void TestGetLatestCycle() { CycleRepository cycle = new CycleRepository(); Assert.AreNotEqual(cycle.GetLatestCycle(), string.Empty); }
public ActionResult Create([Bind(Include = "Detail")] DevelopmentPlanAdd newPlanItem, int? cycle) { try { if (cycle != null) { if (ModelState.IsValid) { int pf = this.empDir.GetEmployeePF(User.Identity.Name); if (pf != -1) { newPlanItem.CycleId = Int32.Parse(cycle.ToString()); // Set the new development plan item cycle. int empId = this.empDir.GetEmployeeId(pf.ToString()); if (empId != -1) { newPlanItem.EmployeeId = empId; if (this.repo.Add(pf, cycle, newPlanItem)) { #region KPI added successfully #region Set the current cycle ViewBag.CurrentCycle = cycle; #endregion #region Other view settings CycleRepository cycleRepo = new CycleRepository(); // // Load the view fields PF, fullname of user and the performance cycle ViewBag.Pf = this.empDir.GetEmployeePF(User.Identity.Name); ViewBag.Fullname = this.empDir.GetFullname(this.empDir.GetEmployeePF(User.Identity.Name)); ViewBag.CycleSelection = cycleRepo.GetCycleSelectionList(Int32.Parse(User.Identity.Name.Substring(8))); if (!string.IsNullOrEmpty(cycleRepo.GetSelectedCycle(Int32.Parse(User.Identity.Name.Substring(8)), cycle))) { ViewBag.Cycle = cycleRepo.GetSelectedCycle(Int32.Parse(User.Identity.Name.Substring(8)), cycle); } else if (!string.IsNullOrEmpty(cycleRepo.GetRunningCycle())) { ViewBag.Cycle = cycleRepo.GetRunningCycle(); } else { ViewBag.Cycle = cycleRepo.GetLatestCycle(); } #endregion // // Get the model to be presented. #region Get the model to be presented IEnumerable<DevelopmentPlanList> model = this.repo.Get(pf, cycle, false); #endregion // // Return the view with the model #region return view return View("Index", model); #endregion #endregion } else { // // Handle failed post. ViewBag.Fullname = this.empDir.GetFullname(this.empDir.GetEmployeePF(User.Identity.Name)); return View("Error"); } } else { // // Handle invalid employee Id. ViewBag.Fullname = this.empDir.GetFullname(this.empDir.GetEmployeePF(User.Identity.Name)); return View("Error"); } } else { // // Handle invalid PF number. ViewBag.Fullname = this.empDir.GetFullname(this.empDir.GetEmployeePF(User.Identity.Name)); return View("Error"); } } else { // // Reload the view int pf = this.empDir.GetEmployeePF(User.Identity.Name); #region Set the current cycle ViewBag.CurrentCycle = cycle; #endregion // // Get the other View bag details if (pf != -1) // ensure that that user is valid { #region Other view settings CycleRepository cycleRepo = new CycleRepository(); // // Load the view fields PF, fullname of user and the performance cycle ViewBag.Pf = this.empDir.GetEmployeePF(User.Identity.Name); ViewBag.Fullname = this.empDir.GetFullname(this.empDir.GetEmployeePF(User.Identity.Name)); ViewBag.CycleSelection = cycleRepo.GetCycleSelectionList(Int32.Parse(User.Identity.Name.Substring(8))); if (!string.IsNullOrEmpty(cycleRepo.GetSelectedCycle(Int32.Parse(User.Identity.Name.Substring(8)), cycle))) { ViewBag.Cycle = cycleRepo.GetSelectedCycle(Int32.Parse(User.Identity.Name.Substring(8)), cycle); } else if (!string.IsNullOrEmpty(cycleRepo.GetRunningCycle())) { ViewBag.Cycle = cycleRepo.GetRunningCycle(); } else { ViewBag.Cycle = cycleRepo.GetLatestCycle(); } #endregion // // Return the view with the model #region return view return View(newPlanItem); #endregion } else { // // Return error view #region Invalid user ViewBag.Fullname = this.empDir.GetFullname(this.empDir.GetEmployeePF(User.Identity.Name)); return View("Error"); #endregion } } } else { // // Handle the performance cycle not being provided. ViewBag.Fullname = this.empDir.GetFullname(this.empDir.GetEmployeePF(User.Identity.Name)); return View("Error"); } } catch (Exception) { // // Handle exception ViewBag.Fullname = this.empDir.GetFullname(this.empDir.GetEmployeePF(User.Identity.Name)); return View("Error"); } }
// // GET: /DevelopmentPlan/Delete/3 public ActionResult Delete(int? cycle, int? id) { if (cycle != null) { int pf = this.empDir.GetEmployeePF(User.Identity.Name); #region Set the current cycle ViewBag.CurrentCycle = cycle; #endregion // // Get the other View bag details if (pf != -1) // ensure that that user is valid { if (this.repo.Delete(pf, cycle, id)) { #region Other view settings CycleRepository cycleRepo = new CycleRepository(); // // Load the view fields PF, fullname of user and the performance cycle ViewBag.Pf = this.empDir.GetEmployeePF(User.Identity.Name); ViewBag.Fullname = this.empDir.GetFullname(this.empDir.GetEmployeePF(User.Identity.Name)); ViewBag.CycleSelection = cycleRepo.GetCycleSelectionList(Int32.Parse(User.Identity.Name.Substring(8))); if (!string.IsNullOrEmpty(cycleRepo.GetSelectedCycle(Int32.Parse(User.Identity.Name.Substring(8)), cycle))) { ViewBag.Cycle = cycleRepo.GetSelectedCycle(Int32.Parse(User.Identity.Name.Substring(8)), cycle); } else if (!string.IsNullOrEmpty(cycleRepo.GetRunningCycle())) { ViewBag.Cycle = cycleRepo.GetRunningCycle(); } else { ViewBag.Cycle = cycleRepo.GetLatestCycle(); } #endregion // // Get the model to be presented. #region Get the model to be presented IEnumerable<DevelopmentPlanList> model = this.repo.Get(pf, cycle, false); #endregion // // Return the view with the model #region return view return View("Index", model); #endregion } else { // // Return error view #region Invalid user return View("Error"); #endregion } } else { // // Return error view #region Invalid user return View("Error"); #endregion } } else { // // Ensure that the performance cycle being process is provided. #region Cycle not provided ViewBag.Fullname = this.empDir.GetFullname(this.empDir.GetEmployeePF(User.Identity.Name)); return View("Error"); #endregion } }
public ActionResult Create([Bind(Include = "KpiTitle, Weight, Measure")] AddKpi newKpi, string EmployeeObjectiveId, int? cycle) { try { if (cycle != null) { if (ModelState.IsValid && EmployeeObjectiveId.Length != 0) { int pf = this.empDir.GetEmployeePF(User.Identity.Name); if (pf != -1) { newKpi.EmployeeObjectiveId = Int32.Parse(EmployeeObjectiveId); if (this.repo.AddKpi(newKpi, pf, cycle)) { #region KPI added successfully #region Set the current cycle ViewBag.CurrentCycle = cycle; #endregion #region Other view settings CycleRepository cycleRepo = new CycleRepository(); // // Load the view fields PF, fullname of user and the performance cycle ViewBag.Pf = this.empDir.GetEmployeePF(User.Identity.Name); ViewBag.Fullname = this.empDir.GetFullname(this.empDir.GetEmployeePF(User.Identity.Name)); ViewBag.CycleSelection = cycleRepo.GetCycleSelectionList(Int32.Parse(User.Identity.Name.Substring(8))); if (!string.IsNullOrEmpty(cycleRepo.GetSelectedCycle(Int32.Parse(User.Identity.Name.Substring(8)), cycle))) { ViewBag.Cycle = cycleRepo.GetSelectedCycle(Int32.Parse(User.Identity.Name.Substring(8)), cycle); } else if (!string.IsNullOrEmpty(cycleRepo.GetRunningCycle())) { ViewBag.Cycle = cycleRepo.GetRunningCycle(); } else { ViewBag.Cycle = cycleRepo.GetLatestCycle(); } #endregion // // Get the model to be presented. #region Get the model to be presented IEnumerable<KpiIndex> model = this.repo.Get(cycle, pf, false); #endregion // // Return the view with the model #region return view return View("Index", model); #endregion #endregion } else { // // Handle failed post. return View("Error"); } } else { // // Handle invalid PF number. return View("Error"); } } else { // // Reload the view int pf = this.empDir.GetEmployeePF(User.Identity.Name); #region Set the current cycle ViewBag.CurrentCycle = cycle; #endregion // // Get the other View bag details if (pf != -1) // ensure that that user is valid { #region Other view settings CycleRepository cycleRepo = new CycleRepository(); // // Load the view fields PF, fullname of user and the performance cycle ViewBag.Pf = this.empDir.GetEmployeePF(User.Identity.Name); ViewBag.Fullname = this.empDir.GetFullname(this.empDir.GetEmployeePF(User.Identity.Name)); ViewBag.CycleSelection = cycleRepo.GetCycleSelectionList(Int32.Parse(User.Identity.Name.Substring(8))); if (!string.IsNullOrEmpty(cycleRepo.GetSelectedCycle(Int32.Parse(User.Identity.Name.Substring(8)), cycle))) { ViewBag.Cycle = cycleRepo.GetSelectedCycle(Int32.Parse(User.Identity.Name.Substring(8)), cycle); } else if (!string.IsNullOrEmpty(cycleRepo.GetRunningCycle())) { ViewBag.Cycle = cycleRepo.GetRunningCycle(); } else { ViewBag.Cycle = cycleRepo.GetLatestCycle(); } // Setup the employee objective selection list. ViewBag.EmployeeObjectiveSelectList = this.objRepo.GetEmployeeObjectiveSelect(cycle, pf); #endregion // // Return the view with the model #region return view return View(newKpi); #endregion } else { // // Return error view #region Invalid user return View("Error"); #endregion } } } else { // // Handle the performance cycle not being provided. return View("Error"); } } catch (Exception) { // // Handle the exception. return View("Error"); } }
public ActionResult Rate([Bind(Include = "KpiId, EmployeeObjectiveId, KpiTitle, Weight, Measure, EmployeeRating, FinalRating")] SelfAssessmentRating er, int? id, int? cycle) { try { if (cycle != null && id != null) { if (ModelState.IsValid) { int pf = this.empDir.GetEmployeePF(User.Identity.Name); if (pf != -1) { if (this.repo.EmployeeRating(pf, cycle, er)) { #region KPI added successfully #region Set the current cycle ViewBag.CurrentCycle = cycle; #endregion #region Other view settings CycleRepository cycleRepo = new CycleRepository(); // // Load the view fields PF, fullname of user and the performance cycle ViewBag.Pf = this.empDir.GetEmployeePF(User.Identity.Name); ViewBag.Fullname = this.empDir.GetFullname(this.empDir.GetEmployeePF(User.Identity.Name)); ViewBag.CycleSelection = cycleRepo.GetCycleSelectionList(Int32.Parse(User.Identity.Name.Substring(8))); if (!string.IsNullOrEmpty(cycleRepo.GetSelectedCycle(Int32.Parse(User.Identity.Name.Substring(8)), cycle))) { ViewBag.Cycle = cycleRepo.GetSelectedCycle(Int32.Parse(User.Identity.Name.Substring(8)), cycle); } else if (!string.IsNullOrEmpty(cycleRepo.GetRunningCycle())) { ViewBag.Cycle = cycleRepo.GetRunningCycle(); } else { ViewBag.Cycle = cycleRepo.GetLatestCycle(); } #endregion // // Get the model to be presented. #region Get the model to be presented IEnumerable<SelfAssessmentIndex> model = this.repo.Get(pf, cycle); #endregion // // Return the view with the model #region return view return View("Index", model); #endregion #endregion } else { // // Handle failed post. return View("ErrorSelfAssessment"); } } else { // // Handle invalid PF number. return View("Error"); } } else { int pf = this.empDir.GetEmployeePF(User.Identity.Name); #region Set the current cycle ViewBag.CurrentCycle = cycle; #endregion // // Get the other View bag details if (pf != -1) // ensure that that user is valid { #region Other view settings CycleRepository cycleRepo = new CycleRepository(); // // Load the view fields PF, fullname of user and the performance cycle ViewBag.Pf = this.empDir.GetEmployeePF(User.Identity.Name); ViewBag.Fullname = this.empDir.GetFullname(this.empDir.GetEmployeePF(User.Identity.Name)); ViewBag.CycleSelection = cycleRepo.GetCycleSelectionList(Int32.Parse(User.Identity.Name.Substring(8))); if (!string.IsNullOrEmpty(cycleRepo.GetSelectedCycle(Int32.Parse(User.Identity.Name.Substring(8)), cycle))) { ViewBag.Cycle = cycleRepo.GetSelectedCycle(Int32.Parse(User.Identity.Name.Substring(8)), cycle); } else if (!string.IsNullOrEmpty(cycleRepo.GetRunningCycle())) { ViewBag.Cycle = cycleRepo.GetRunningCycle(); } else { ViewBag.Cycle = cycleRepo.GetLatestCycle(); } #endregion // // Get the model to be presented. #region Get the model to be presented SelfAssessmentRating model = this.repo.RatingGet(pf, cycle, id); #endregion // // Return the view with the model #region return view return View(model); #endregion } else { // // Return error view #region Invalid user ViewBag.Fullname = this.empDir.GetFullname(this.empDir.GetEmployeePF(User.Identity.Name)); return View("Error"); #endregion } } } else { // // Handle invalid url ViewBag.Fullname = this.empDir.GetFullname(this.empDir.GetEmployeePF(User.Identity.Name)); return View("Error"); } } catch (Exception) { ViewBag.Fullname = this.empDir.GetFullname(this.empDir.GetEmployeePF(User.Identity.Name)); return View("Error"); } }
public ActionResult Index(int? cycle) { IKpiRepository kpiRepo = new KpiRepository(); Dashboard model = new Dashboard(); if (cycle != null) { model = kpiRepo.GetDashboardDetails(this.empDir.GetEmployeePF(User.Identity.Name), cycle); CycleRepository cycleRepo = new CycleRepository(); ViewBag.Pf = this.empDir.GetEmployeePF(User.Identity.Name); ViewBag.Fullname = this.empDir.GetFullname(this.empDir.GetEmployeePF(User.Identity.Name)); ViewBag.CycleSelection = cycleRepo.GetCycleSelectionList(Int32.Parse(User.Identity.Name.Substring(8))); if (!string.IsNullOrEmpty(cycleRepo.GetSelectedCycle(Int32.Parse(User.Identity.Name.Substring(8)), cycle))) { ViewBag.Cycle = cycleRepo.GetSelectedCycle(Int32.Parse(User.Identity.Name.Substring(8)), cycle); } else if (!string.IsNullOrEmpty(cycleRepo.GetRunningCycle())) { ViewBag.Cycle = cycleRepo.GetRunningCycle(); } else { ViewBag.Cycle = cycleRepo.GetLatestCycle(); } // Set the scores for the dashboard int? fr = kpiRepo.GetFinalScore(this.empDir.GetEmployeePF(User.Identity.Name), cycle); int? er = kpiRepo.GetEmployeeScore(this.empDir.GetEmployeePF(User.Identity.Name), cycle); ViewBag.FinalRating = fr; ViewBag.EmployeeRating = er; //Get the comments ViewBag.EmployeeComments = kpiRepo.GetEmployeeComments(this.empDir.GetEmployeePF(User.Identity.Name), cycle); ViewBag.SupervisorComments = kpiRepo.GetSupervisorComments(this.empDir.GetEmployeePF(User.Identity.Name), cycle); } else { CycleRepository cycleRepo = new CycleRepository(); ViewBag.Pf = this.empDir.GetEmployeePF(User.Identity.Name); ViewBag.Fullname = this.empDir.GetFullname(this.empDir.GetEmployeePF(User.Identity.Name)); ViewBag.CycleSelection = cycleRepo.GetCycleSelectionList(Int32.Parse(User.Identity.Name.Substring(8))); if (!string.IsNullOrEmpty(cycleRepo.GetRunningCycle())) { string _cycleString = cycleRepo.GetRunningCycle(); ViewBag.Cycle = _cycleString; string cycleStr = _cycleString; char[] sp = { ',' }; String[] link = cycleStr.Split(sp); cycle = Int32.Parse(link[0].ToString()); model = kpiRepo.GetDashboardDetails(this.empDir.GetEmployeePF(User.Identity.Name), cycle); // Set the scores for the dashboard int? fr = kpiRepo.GetFinalScore(this.empDir.GetEmployeePF(User.Identity.Name), cycle); int? er = kpiRepo.GetEmployeeScore(this.empDir.GetEmployeePF(User.Identity.Name), cycle); ViewBag.FinalRating = fr; ViewBag.EmployeeRating = er; // Get the comments ViewBag.EmployeeComments = kpiRepo.GetEmployeeComments(this.empDir.GetEmployeePF(User.Identity.Name), cycle); ViewBag.SupervisorComments = kpiRepo.GetSupervisorComments(this.empDir.GetEmployeePF(User.Identity.Name), cycle); } else { string _cycleString = cycleRepo.GetLatestCycle();; ViewBag.Cycle = _cycleString; string cycleStr = _cycleString; char[] sp = { ',' }; String[] link = cycleStr.Split(sp); cycle = Int32.Parse(link[0].ToString()); model = kpiRepo.GetDashboardDetails(this.empDir.GetEmployeePF(User.Identity.Name), cycle); // Set the scores for the dashboard int? fr = kpiRepo.GetFinalScore(this.empDir.GetEmployeePF(User.Identity.Name), cycle); int? er = kpiRepo.GetEmployeeScore(this.empDir.GetEmployeePF(User.Identity.Name), cycle); ViewBag.FinalRating = fr; ViewBag.EmployeeRating = er; // Get the comments ViewBag.EmployeeComments = kpiRepo.GetEmployeeComments(this.empDir.GetEmployeePF(User.Identity.Name), cycle); ViewBag.SupervisorComments = kpiRepo.GetSupervisorComments(this.empDir.GetEmployeePF(User.Identity.Name), cycle); } } return View(model); }
public ActionResult Create([Bind(Include = "Objective, Weight")]AddObjective newObjective, int? cycle, string CycleId) { if (cycle != null) { try { if (ModelState.IsValid && CycleId.Length != 0) { // // Setup the object to be submit newObjective.CycleId = Int32.Parse(CycleId); int pf = this.empDir.GetEmployeePF(User.Identity.Name); if (pf != -1) { if (this.objRepo.AddObjective(newObjective, pf)) { CycleRepository cycleRepo = new CycleRepository(); // // Load the view fields PF, fullname of user and the performance cycle ViewBag.Pf = this.empDir.GetEmployeePF(User.Identity.Name); ViewBag.Fullname = this.empDir.GetFullname(this.empDir.GetEmployeePF(User.Identity.Name)); ViewBag.CycleSelection = cycleRepo.GetCycleSelectionList(Int32.Parse(User.Identity.Name.Substring(8))); if (!string.IsNullOrEmpty(cycleRepo.GetSelectedCycle(Int32.Parse(User.Identity.Name.Substring(8)), cycle))) { ViewBag.Cycle = cycleRepo.GetSelectedCycle(Int32.Parse(User.Identity.Name.Substring(8)), cycle); } else if (!string.IsNullOrEmpty(cycleRepo.GetRunningCycle())) { ViewBag.Cycle = cycleRepo.GetRunningCycle(); } else { ViewBag.Cycle = cycleRepo.GetLatestCycle(); } // return action result view with query string ViewBag.CurrentCycle = cycle; IEnumerable<ObjectivesList> model = this.objRepo.Get(cycle, this.empDir.GetEmployeePF(User.Identity.Name)); return View("Index", model); } else { return View("Error"); } } else { return View("Error"); } } else { ViewBag.CurrentCycle = cycle; // // Load the performance cycle ViewBag.Pf = this.empDir.GetEmployeePF(User.Identity.Name); ViewBag.Fullname = this.empDir.GetFullname(this.empDir.GetEmployeePF(User.Identity.Name)); ViewBag.CycleSelection = this.cycleRepo.GetCycleSelectionList(Int32.Parse(User.Identity.Name.Substring(8))); if (!string.IsNullOrEmpty(this.cycleRepo.GetSelectedCycle(Int32.Parse(User.Identity.Name.Substring(8)), cycle))) { ViewBag.Cycle = this.cycleRepo.GetSelectedCycle(Int32.Parse(User.Identity.Name.Substring(8)), cycle); } else if (!string.IsNullOrEmpty(cycleRepo.GetRunningCycle())) { ViewBag.Cycle = this.cycleRepo.GetRunningCycle(); } else { ViewBag.Cycle = this.cycleRepo.GetLatestCycle(); } // // Get the user's PF number. int pf = this.empDir.GetEmployeePF(User.Identity.Name); // // Check that the PF number returned is valid. if (pf != -1) { ViewBag.CycleSelectList = this.cycleRepo.GetCycleDropSelectList(pf); // // Return View newObjective.Weight = Int32.Parse(newObjective.Weight.ToString()); newObjective.Objective = newObjective.Objective; return View(newObjective); } else { // // If PF number returned is invalid handle error. return View("Error"); } } } catch (Exception) { return View("Error"); } } else { return View("Error"); } }
// // GET: /Objective/ public ActionResult Index(int? cycle) { if (cycle != null) { ViewBag.CurrentCycle = cycle; if (this.empDir.GetEmployeePF(User.Identity.Name) != -1) { CycleRepository cycleRepo = new CycleRepository(); // // Load the view fields PF, fullname of user and the performance cycle ViewBag.Pf = this.empDir.GetEmployeePF(User.Identity.Name); ViewBag.Fullname = this.empDir.GetFullname(this.empDir.GetEmployeePF(User.Identity.Name)); ViewBag.CycleSelection = cycleRepo.GetCycleSelectionList(Int32.Parse(User.Identity.Name.Substring(8))); if (!string.IsNullOrEmpty(cycleRepo.GetSelectedCycle(Int32.Parse(User.Identity.Name.Substring(8)), cycle))) { ViewBag.Cycle = cycleRepo.GetSelectedCycle(Int32.Parse(User.Identity.Name.Substring(8)), cycle); } else if (!string.IsNullOrEmpty(cycleRepo.GetRunningCycle())) { ViewBag.Cycle = cycleRepo.GetRunningCycle(); } else { ViewBag.Cycle = cycleRepo.GetLatestCycle(); } // // Get the model to be presented. int pf = this.empDir.GetEmployeePF(User.Identity.Name); IEnumerable<ObjectivesList> model = this.objRepo.Get(cycle, pf); // // Return the view with the model return View(model); } else { // // Return error view return View("Error"); } } else { // // Ensure that the performance cycle being process is provided. ViewBag.Fullname = this.empDir.GetFullname(this.empDir.GetEmployeePF(User.Identity.Name)); return View("Error"); } }