public CommunityMember convertMainObjectToCommunityMember(MainObjectFromCsvFileInfo mainObject) { CommunityMember communityMemberVm = new CommunityMember(); if(string.IsNullOrWhiteSpace(mainObject.FatherFirstName) && string.IsNullOrWhiteSpace(mainObject.FatherLastName)) { communityMemberVm.FirstName = string.IsNullOrWhiteSpace(mainObject.MotherFirstName) ? "N/A" : mainObject.MotherFirstName; communityMemberVm.LastName = string.IsNullOrWhiteSpace(mainObject.MotherLastName) ? "N/A" : mainObject.MotherLastName; } else { communityMemberVm.FirstName = string.IsNullOrWhiteSpace(mainObject.FatherFirstName)? "N/A" : mainObject.FatherFirstName; communityMemberVm.LastName = string.IsNullOrWhiteSpace(mainObject.FatherLastName)? "N/A" : mainObject.FatherLastName; communityMemberVm.SpouseFirstName = string.IsNullOrWhiteSpace(mainObject.MotherFirstName)? "N/A" : mainObject.MotherFirstName; communityMemberVm.SpouseLastName = string.IsNullOrWhiteSpace(mainObject.MotherLastName)? "N/A" : mainObject.MotherLastName; } communityMemberVm.PhoneNumber = mainObject.FatherPhone; communityMemberVm.SpousePhoneNumber = mainObject.MotherPhone; communityMemberVm.Email = "*****@*****.**"; if (mainObject.Children != null && mainObject.Children.Count() > 0) { communityMemberVm.Children = new List<Child>(); for (int i = 0; i < mainObject.Children.Count(); i++) { var mainObjectChild = mainObject.Children[i]; Child child = new Child(); child.FirstName = mainObjectChild.ChildFirstName; child.LastName = string.IsNullOrWhiteSpace(communityMemberVm.LastName) ? "" : communityMemberVm.LastName; child.Gender = mainObjectChild.Gender; child.DateOfBirth = new Extentions().getDobFromAge(mainObjectChild.Age); communityMemberVm.Children.Add(child); } } return communityMemberVm; }
public List <MainObjectFromCsvFileInfo> readCsvFile() { StreamReader reader = new StreamReader(File.OpenRead("C:/Users/Abdo/Desktop/mesjidRegistrationFile.csv")); List <MainObjectFromCsvFileInfo> listA = new List <MainObjectFromCsvFileInfo>(); var ind = 0; while (!reader.EndOfStream) { var line = reader.ReadLine(); if (ind > 1) { //int i = -1; var values = line.Split(','); MainObjectFromCsvFileInfo mObject = new MainObjectFromCsvFileInfo( values[0], values[1], string.IsNullOrWhiteSpace(values[2])? 0000000 : double.Parse(values[2]), values[3], values[4], string.IsNullOrWhiteSpace(values[5])? 0000000 : double.Parse(values[5]) ); for (int i = 6; i < 16; i += 3) { int index = i - 1; if (!string.IsNullOrWhiteSpace(values[i])) { mObject.Children.Add(new ChildObjectFromCsvFileInfo( values[++index], string.IsNullOrWhiteSpace(values[index + 1]) ? 0 : int.Parse(values[++index]), values[++index])); } } listA.Add(mObject); } ind++; } reader.Close(); return(listA); }
public CommunityMember convertMainObjectToCommunityMember(MainObjectFromCsvFileInfo mainObject) { CommunityMember communityMemberVm = new CommunityMember(); if (string.IsNullOrWhiteSpace(mainObject.FatherFirstName) && string.IsNullOrWhiteSpace(mainObject.FatherLastName)) { communityMemberVm.FirstName = string.IsNullOrWhiteSpace(mainObject.MotherFirstName) ? "N/A" : mainObject.MotherFirstName; communityMemberVm.LastName = string.IsNullOrWhiteSpace(mainObject.MotherLastName) ? "N/A" : mainObject.MotherLastName; } else { communityMemberVm.FirstName = string.IsNullOrWhiteSpace(mainObject.FatherFirstName)? "N/A" : mainObject.FatherFirstName; communityMemberVm.LastName = string.IsNullOrWhiteSpace(mainObject.FatherLastName)? "N/A" : mainObject.FatherLastName; communityMemberVm.SpouseFirstName = string.IsNullOrWhiteSpace(mainObject.MotherFirstName)? "N/A" : mainObject.MotherFirstName; communityMemberVm.SpouseLastName = string.IsNullOrWhiteSpace(mainObject.MotherLastName)? "N/A" : mainObject.MotherLastName; } communityMemberVm.PhoneNumber = mainObject.FatherPhone; communityMemberVm.SpousePhoneNumber = mainObject.MotherPhone; communityMemberVm.Email = "*****@*****.**"; if (mainObject.Children != null && mainObject.Children.Count() > 0) { communityMemberVm.Children = new List <Child>(); for (int i = 0; i < mainObject.Children.Count(); i++) { var mainObjectChild = mainObject.Children[i]; Child child = new Child(); child.FirstName = mainObjectChild.ChildFirstName; child.LastName = string.IsNullOrWhiteSpace(communityMemberVm.LastName) ? "" : communityMemberVm.LastName; child.Gender = mainObjectChild.Gender; child.DateOfBirth = new Extentions().getDobFromAge(mainObjectChild.Age); communityMemberVm.Children.Add(child); } } return(communityMemberVm); }
public List<MainObjectFromCsvFileInfo> readCsvFile() { StreamReader reader = new StreamReader(File.OpenRead("C:/Users/Abdo/Desktop/mesjidRegistrationFile.csv")); List<MainObjectFromCsvFileInfo> listA = new List<MainObjectFromCsvFileInfo>(); var ind = 0; while (!reader.EndOfStream) { var line = reader.ReadLine(); if (ind > 1) { //int i = -1; var values = line.Split(','); MainObjectFromCsvFileInfo mObject = new MainObjectFromCsvFileInfo( values[0], values[1], string.IsNullOrWhiteSpace(values[2])? 0000000 : double.Parse(values[2]), values[3], values[4], string.IsNullOrWhiteSpace(values[5])? 0000000 : double.Parse(values[5]) ); for (int i = 6; i < 16; i += 3) { int index = i - 1; if (!string.IsNullOrWhiteSpace(values[i])) { mObject.Children.Add(new ChildObjectFromCsvFileInfo( values[++index], string.IsNullOrWhiteSpace(values[index + 1]) ? 0 : int.Parse(values[++index]), values[++index])); } } listA.Add(mObject); } ind++; } reader.Close(); return listA; }