public ActionResult AddDiscipline(DisciplineView disciplineView) { //Check that Training Info is Not Null if (disciplineView == null) { throw new ArgumentNullException(nameof(disciplineView)); } //Validate Model if (!ModelState.IsValid) { var model = this.disciplineService.GetDisciplineView(disciplineView, string.Empty); return(View("AddDiscipline", model)); } //Process The Training Information var processingMessage = disciplineService.ProcessDisciplineInfo(disciplineView); //Check if the Processing Message is Not Empty //If it is not empty, Means there is no error if (!string.IsNullOrEmpty(processingMessage)) { var model = this.disciplineService.GetDisciplineView(disciplineView, processingMessage); return(this.View("AddDiscipline", model)); } processingMessage = string.Format("New Discipline is Added"); return(this.RedirectToAction("EmployeeDisciplineList", new { employeeId = disciplineView.EmployeeId, message = processingMessage })); }
public ActionResult EditDiscipline(DisciplineView disciplineView) { if (disciplineView == null) { throw new ArgumentNullException(nameof(disciplineView)); } if (!ModelState.IsValid) { var model = this.disciplineService.GetDisciplineView(disciplineView, string.Empty); return(View("EditDiscipline", model)); } var processingMessage = disciplineService.ProcessEditDisciplineInfo(disciplineView); if (!string.IsNullOrEmpty(processingMessage)) { var model = this.disciplineService.GetDisciplineView(disciplineView, processingMessage); return(this.View("EditDiscipline", model)); } processingMessage = string.Format("{0} Updated", disciplineView.Offence); return(this.RedirectToAction("DisciplineList", new { message = processingMessage })); }
/// <summary> /// Creates the discipline view. /// </summary> /// <param name="companyCollection">The company collection.</param> /// <param name="queryStatus">The query status.</param> /// <param name="actionTaken">The action taken.</param> /// <returns></returns> /// <exception cref="ArgumentNullException"> /// companyCollection /// or /// queryStatus /// or /// actionTaken /// </exception> public IDisciplineView CreateDisciplineView(int employeeId, int companyId, IList <IEmployee> employeeCollection, IList <IQueryStatus> queryStatus, IList <IActionTaken> actionTaken) { if (queryStatus == null) { throw new ArgumentNullException(nameof(queryStatus)); } if (actionTaken == null) { throw new ArgumentNullException(nameof(actionTaken)); } if (employeeCollection == null) { throw new ArgumentNullException(nameof(employeeCollection)); } var queryDDL = GetDropDownList.QueryStatusListItem(queryStatus, -1); var actionTakenDDL = GetDropDownList.ActionTakenListItem(actionTaken, -1); var employeeDDL = GetDropDownList.EmployeeListitems(employeeCollection, -1); var result = new DisciplineView { QueryDropDown = queryDDL, ActionTakenDropDown = actionTakenDDL, EmployeeDropDown = employeeDDL, EmployeeId = employeeId, CompanyId = companyId, ProcessingMessage = string.Empty }; return(result); }
public ActionResult SetClassDiscipline(ClassDisciplineInputModel discipline) { if (!Context.PersonId.HasValue) { throw new UnassignedUserException(); } IList <Infraction> infractions = null; if (discipline.InfractionsIds != null && discipline.InfractionsIds.Count > 0) { infractions = SchoolLocator.InfractionService.GetInfractions(); infractions = infractions.Where(x => discipline.InfractionsIds.Contains(x.Id)).ToList(); } var classDisciplineModel = new ClassDiscipline { ClassId = discipline.ClassId, Date = discipline.Date, Id = discipline.Id, Description = discipline.Description, Infractions = infractions ?? new List <Infraction>(), StudentId = discipline.StudentId }; var res = SchoolLocator.DisciplineService.SetClassDiscipline(classDisciplineModel); MasterLocator.UserTrackingService.SetDiscipline(Context.Login, classDisciplineModel.ClassId, classDisciplineModel.Date, classDisciplineModel.Description, classDisciplineModel.StudentId); return(Json(DisciplineView.Create(res, Context.PersonId.Value))); }
public static DisciplineMonthCalendarViewData Create(DateTime date, bool isCurrentMonth, int currentPersonId, IList <ClassDisciplineDetails> disciplines) { disciplines = disciplines.Where(x => x.Date.Date == date.Date).ToList(); var dscViewDataList = DisciplineView.Create(disciplines, currentPersonId); var dscTypesList = new List <DisciplineTypeViewData>(); var moreCount = 0; foreach (var discipline in dscViewDataList) { dscTypesList.AddRange(discipline.DisciplineTypes); } var sortedDisciplineTypes = dscTypesList .GroupBy(x => x.Id) .ToDictionary(x => x.Key, x => x.ToList()) .OrderByDescending(x => x.Value.Count) .Select(x => new DisciplineTypeCalendarItemViewData { Id = x.Key, Name = x.Value.First().Name, Count = x.Value.Count, }).ToList(); if (sortedDisciplineTypes.Count > DISCIPLINE_COUNT) { moreCount = sortedDisciplineTypes.Skip(DISCIPLINE_COUNT).Sum(x => x.Count); } return(new DisciplineMonthCalendarViewData(date, isCurrentMonth) { HasDisciplineIssues = sortedDisciplineTypes.Count > 1, Disciplines = dscViewDataList, MoreCount = moreCount, }); }
/// <summary> /// Creates the edit discipling view. /// </summary> /// <param name="discipline">The discipline.</param> /// <param name="employeeCollection">The employee collection.</param> /// <param name="queryStatusCollecction">The query status collecction.</param> /// <param name="actionTaken">The action taken.</param> /// <returns></returns> /// <exception cref="ArgumentNullException"> /// queryStatusCollecction /// or /// actionTaken /// or /// employeeCollection /// </exception> public IDisciplineView CreateEditDisciplingView(IDiscipline discipline, IList <IEmployee> employeeCollection, IList <IQueryStatus> queryStatusCollecction, IList <IActionTaken> actionTaken) { if (queryStatusCollecction == null) { throw new ArgumentNullException(nameof(queryStatusCollecction)); } if (actionTaken == null) { throw new ArgumentNullException(nameof(actionTaken)); } if (employeeCollection == null) { throw new ArgumentNullException(nameof(employeeCollection)); } var queryDDL = GetDropDownList.QueryStatusListItem(queryStatusCollecction, discipline.QueryStatusId); var actionTakenDDL = GetDropDownList.ActionTakenListItem(actionTaken, discipline.ActionTakenId); var employeeDDL = GetDropDownList.EmployeeListitems(employeeCollection, discipline.EmployeeId); var result = new DisciplineView { DisciplineId = discipline.DisciplineId, EmployeeId = discipline.EmployeeId, QueryStatusId = discipline.QueryStatusId, QueryDate = discipline.QueryDate, Offence = discipline.Offence, QueryInitiator = discipline.QueryInitiator, Investigator = discipline.Investigator, Response = discipline.Response, InvestigatorReport = discipline.InvestigatorReport, RecommendedSanction = discipline.RecommendedSanction, DisciplineCommitteeRecommendation = discipline.DisciplineCommitteeRecommendation, ActionTakenId = discipline.ActionTakenId, EvidenceDigitalFileId = discipline.EvidenceDigitalFileId, DateCreated = discipline.DateCreated, CompanyId = discipline.CompanyId, QueryDropDown = queryDDL, ActionTakenDropDown = actionTakenDDL, EmployeeDropDown = employeeDDL, ProcessingMessage = string.Empty }; return(result); }
public ActionResult ClassList(DateTime?date, int classId, int?start, int?count, bool?byLastName) { start = start ?? 0; count = count ?? int.MaxValue; var currentDate = (date ?? SchoolLocator.Context.NowSchoolYearTime).Date; var disciplines = SchoolLocator.DisciplineService.GetClassDisciplineDetails(classId, currentDate); IList <DisciplineView> res = new List <DisciplineView>(); if (disciplines != null) { res = DisciplineView.Create(disciplines, Context.PersonId ?? 0).ToList(); } if (!byLastName.HasValue || byLastName.Value) { res = res.OrderBy(x => x.Student.LastName).ThenBy(x => x.Student.FirstName).ToList(); } else { res = res.OrderBy(x => x.Student.FirstName).ThenBy(x => x.Student.LastName).ToList(); } return(Json(new PaginatedList <DisciplineView>(res, start.Value / count.Value, count.Value))); }