public static List <BranchStudentDto> Convert(BranchesStudents studentBranches) { if (studentBranches != null) { List <BranchStudentDto> studentBranchDto = new List <BranchStudentDto>(); foreach (BranchStudent studentBranch in studentBranches) { BranchStudentDto item = Convert(studentBranch); studentBranchDto.Add(item); } return(studentBranchDto); } return(null); }
public static BranchesStudents Convert(List <BranchStudentDto> studentBranchsDto) { if (studentBranchsDto != null) { BranchesStudents studentsBranchs = new BranchesStudents(); foreach (BranchStudentDto studentBranch in studentBranchsDto) { BranchStudent item = Convert(studentBranch); studentsBranchs.Add(item); } return(studentsBranchs); } return(null); }
public static BranchesStudents TableToBranchStudent(DataTable table, Student.Includes includes = Student.Includes.None) { if (table == null) { return(null); } BranchesStudents branchesStudents = new BranchesStudents(); foreach (DataRow row in table.Rows) { branchesStudents.Add(RowToBranchStudent(table.AsEnumerable(), includes)); } return(branchesStudents); }
public static int SetBranchOfStudentInactive(int studentId) { try { int update = 0; BranchesStudents branchesStudent = BranchStudentDataManager.GetActiveBranchesOfStudent(studentId, Student.Includes.Branch); string releaseHebrewDate = DateConverter.GetHebrewDate(DateTime.UtcNow); foreach (BranchStudent branchStudent in branchesStudent) { update = BranchStudentDataManager.SetStudentInactiveInBranch(studentId, branchStudent.Branch.Id, releaseHebrewDate); BranchManager.ReduceNumberOfStudents(branchStudent.Branch.Id); } return(update); } catch (Exception ex) { _logger.Debug("Failed to set the student to inactive in his branches."); throw; } }
public static Student RowToStudent(IEnumerable <DataRow> rows, Student.Includes include) { DataRow row = rows.FirstOrDefault(); BranchesStudents branchesStudent = new BranchesStudents(); if (include.HasFlag(Student.Includes.BranchStudent)) { var studentInstoitutionList = rows.GroupBy(studentRow => DataRowHelper.GetValue <int>(studentRow, Tables.BranchStudents.Id.FullName), (id, group) => BranchStudentConverter.RowToBranchStudent(group.CopyToDataTable().AsEnumerable(), Student.Includes.Branch)).ToList(); branchesStudent.AddRange(studentInstoitutionList); } return(new Student() { FirstName = DataRowHelper.GetValue <string>(row, Tables.Students.FirstName.FullName), LastName = DataRowHelper.GetValue <string>(row, Tables.Students.LastName.FullName), AccountNumber = DataRowHelper.GetValue <string>(row, Tables.Students.AccountNumber.FullName), Bank = include.HasFlag(Student.Includes.Bank) ? BankConverter.RowToBank(row) : null, Address = include.HasFlag(Student.Includes.Address) ? AddressConverter.RowToAddress(row) : null, BornDate = DataRowHelper.GetValue <DateTime>(row, Tables.Students.BornDate.FullName), PhoneNumber = DataRowHelper.GetValue <string>(row, Tables.Students.PhoneNumber.FullName), CellphoneNumber = DataRowHelper.GetValue <string>(row, Tables.Students.CellphoneNumber.FullName), ChildrenNumber = DataRowHelper.GetValue <int>(row, Tables.Students.ChildrenNumber.FullName), FaxNumber = DataRowHelper.GetValue <string>(row, Tables.Students.FaxNumber.FullName), IdCard = DataRowHelper.GetValue <string>(row, Tables.Students.IdCard.FullName), IdentityNumber = DataRowHelper.GetValue <string>(row, Tables.Students.IdentityNumber.FullName), Image = DataRowHelper.GetValue <string>(row, Tables.Students.Image.FullName), JobWife = DataRowHelper.GetValue <string>(row, Tables.Students.JobWife.FullName), MarriedChildrenNumber = DataRowHelper.GetValue <int>(row, Tables.Students.MarriedChildrenNumber.FullName), MonthlyIncome = DataRowHelper.GetValue <decimal>(row, Tables.Students.MonthlyIncome.FullName), Id = DataRowHelper.GetValue <int>(row, Tables.Students.Id.FullName), TravelExpenses = DataRowHelper.GetValue <decimal>(row, Tables.Students.TravelExpenses.FullName), WifeName = DataRowHelper.GetValue <string>(row, Tables.Students.WifeName.FullName), StudentChildren = include.HasFlag(Student.Includes.Children) ? rows.GroupBy(studentRow => DataRowHelper.GetValue <int>(studentRow, Tables.StudentsChildren.Id.FullName), (id, child) => StudentChildrenConverter.RowToStudentChildren(child.CopyToDataTable().AsEnumerable())).ToList() : null, StudentBranches = include.HasFlag(Student.Includes.BranchStudent) ? branchesStudent : null, IsActive = DataRowHelper.GetValue <bool>(row, Tables.Students.IsActive.FullName) }); }
public static int SetStudentInactiveInBranch(int studentId, int branchId) { try { string releaseHebrewDate = DateConverter.GetHebrewDate(DateTime.UtcNow); int update = BranchStudentDataManager.SetStudentInactiveInBranch(studentId, branchId, releaseHebrewDate); if (update == 1) { BranchManager.ReduceNumberOfStudents(branchId); } BranchesStudents branchStudents = BranchStudentDataManager.GetActiveBranchesOfStudent(studentId); if (branchStudents.Count() == 0) { StudentDataManager.SetStudentInactive(studentId); } return(update); } catch (Exception) { _logger.Debug("Failed to set the student to inactive in this branch."); throw; } }