public static FamilyModel FromTblFamilies(TblFamilies tblFamilies) { FamilyModel familyModel = new FamilyModel() { FamilyId = tblFamilies.FamilyId, FamilyUUID = tblFamilies.FamilyUUID, InsureeId = tblFamilies.InsureeId, InsureeUUID = tblFamilies.Insuree.InsureeUUID, LocationId = TypeCast.GetValue <int>(tblFamilies.LocationId), Poverty = TypeCast.GetValue <bool>(tblFamilies.Poverty), FamilyType = tblFamilies.FamilyType, FamilyAddress = tblFamilies.FamilyAddress, Ethnicity = tblFamilies.Ethnicity, ConfirmationNo = tblFamilies.ConfirmationNo, ConfirmationType = tblFamilies.ConfirmationType, IsOffline = TypeCast.GetValue <bool>(tblFamilies.IsOffline), Insurees = tblFamilies.TblInsuree .Where(i => i.ValidityTo == null) .Select(i => InsureeModel.FromTblInsuree(i)) .ToList(), FamilySMS = tblFamilies.TblFamilySMS.Where(sms => sms.ValidityTo == null).Select(s => FamilySMS.FromTblFamilySMS(s)).LastOrDefault() }; return(familyModel); }
public static LocationModel FromTblLocation(TblLocations tblLocation) { LocationModel locationModel = new LocationModel() { LocationId = tblLocation.LocationId, LocationCode = tblLocation.LocationCode, LocationName = tblLocation.LocationName, LocationType = tblLocation.LocationType, ParentLocationId = tblLocation.ParentLocationId, ValidFrom = tblLocation.ValidityFrom, ValidTo = tblLocation.ValidityTo, MalePopulation = TypeCast.GetValue <int>(tblLocation.MalePopulation), FemalePopulation = TypeCast.GetValue <int>(tblLocation.FemalePopulation), OtherPopulation = TypeCast.GetValue <int>(tblLocation.OtherPopulation), Families = TypeCast.GetValue <int>(tblLocation.Families) }; return(locationModel); }
public static PhotoModel FromTblPhoto(TblPhotos tblPhoto) { if (tblPhoto == null) { return(null); } PhotoModel photoModel = new PhotoModel() { PhotoId = tblPhoto.PhotoId, Insuree = InsureeModel.FromTblInsuree(tblPhoto.TblInsuree.FirstOrDefault()), CHFID = tblPhoto.Chfid, PhotoFolder = tblPhoto.PhotoFolder, PhotoFileName = tblPhoto.PhotoFileName, OfficerId = tblPhoto.OfficerId, PhotoDate = tblPhoto.PhotoDate, ValidFrom = tblPhoto.ValidityFrom, ValidTo = TypeCast.GetValue <DateTime>(tblPhoto.ValidityTo) }; return(photoModel); }
public async Task <LocationModel[]> GetAllLocations() { LocationModel[] locations; using (var imisContext = new ImisDB()) { TblLocations[] allLocations = await imisContext.TblLocations .Where(l => l.ValidityTo == null) .Select(l => l) .ToArrayAsync(); locations = imisContext.TblLocations .Where(l => l.ParentLocationId == null) .Select(l => new LocationModel() { LocationId = l.LocationId, LocationCode = l.LocationCode, LocationName = l.LocationName, LocationType = l.LocationType, ValidFrom = l.ValidityFrom, ValidTo = l.ValidityTo, MalePopulation = TypeCast.GetValue <int>(l.MalePopulation), FemalePopulation = TypeCast.GetValue <int>(l.FemalePopulation), OtherPopulation = TypeCast.GetValue <int>(l.OtherPopulation), Families = TypeCast.GetValue <int>(l.Families), Locations = GetChildLocations(allLocations, l.LocationId) }) .ToArray(); if (locations == null) { return(null); } } return(locations); }
private static List <LocationModel> GetChildLocations(TblLocations[] allLocations, int parentId) { using (var imisContext = new ImisDB()) { return(allLocations .Where(l => l.ParentLocationId == parentId) .Select(l => new LocationModel() { LocationId = l.LocationId, LocationCode = l.LocationCode, LocationName = l.LocationName, LocationType = l.LocationType, ValidFrom = l.ValidityFrom, ValidTo = l.ValidityTo, MalePopulation = TypeCast.GetValue <int>(l.MalePopulation), FemalePopulation = TypeCast.GetValue <int>(l.FemalePopulation), OtherPopulation = TypeCast.GetValue <int>(l.OtherPopulation), Families = TypeCast.GetValue <int>(l.Families), Locations = GetChildLocations(allLocations, l.LocationId) }) .ToList()); } }
//public InsureeModel(TblInsuree tblInsuree):base() //{ // this.FromTblInsuree(tblInsuree); //} public static InsureeModel FromTblInsuree(TblInsuree tblInsuree) { if (tblInsuree == null) { return(null); } InsureeModel insuree = new InsureeModel() { InsureeId = tblInsuree.InsureeId, IdentificationNumber = tblInsuree.Passport, CHFID = tblInsuree.Chfid, LastName = tblInsuree.LastName, OtherNames = tblInsuree.OtherNames, DOB = tblInsuree.Dob, IsHead = tblInsuree.IsHead, Phone = tblInsuree.Phone, Gender = tblInsuree.Gender, Marital = tblInsuree.Marital, TypeOfId = tblInsuree.TypeOfId, CardIssued = tblInsuree.CardIssued, Email = tblInsuree.Email, CurrentAddress = tblInsuree.CurrentAddress, GeoLocation = tblInsuree.GeoLocation, IdentificationTypes = tblInsuree.TypeOfId, /// todo: link to the table value ValidFrom = tblInsuree.ValidityFrom, ValidTo = TypeCast.GetValue <DateTime>(tblInsuree.ValidityTo) }; if (tblInsuree.Relationship != null) { insuree.Relationship = (short)tblInsuree.Relationship; /// TODO: link to the detailed table } if (tblInsuree.Profession != null) { insuree.Profession = TypeCast.GetValue <short>(tblInsuree.Profession); /// TODO: link to the detailed table } if (tblInsuree.Education != null) { insuree.Education = TypeCast.GetValue <short>(tblInsuree.Education); /// TODO: link to the detailed table } if (tblInsuree.Hfid != null) { insuree.HFID = (short)tblInsuree.Hfid; } if (tblInsuree.IsOffline != null) { insuree.IsOffline = (bool)tblInsuree.IsOffline; } if (tblInsuree.CurrentVillage != null) { insuree.CurrentVillage = new LocationModel() { LocationId = TypeCast.GetValue <int>(tblInsuree.CurrentVillage) // todo: is there any link missing? }; } //if (tblInsuree.Gender != null) { // insuree.Gender = tblInsuree.Gender[0]; //} //if (tblInsuree.Marital != null) //{ // insuree.Marital = tblInsuree.Marital[0]; //} //if (tblInsuree.TypeOfId!= null) //{ // insuree.TypeOfId = tblInsuree.TypeOfId[0]; //} if (tblInsuree.Photo != null) { insuree.Photo = PhotoModel.FromTblPhoto(tblInsuree.Photo); } return(insuree); }
public static InsureeModel FromTblInsuree(TblInsuree tblInsuree) { if (tblInsuree == null) { return(null); } InsureeModel insuree = new InsureeModel() { InsureeId = tblInsuree.InsureeId, InsureeUUID = tblInsuree.InsureeUUID, IdentificationNumber = tblInsuree.Passport, CHFID = tblInsuree.Chfid, LastName = tblInsuree.LastName, OtherNames = tblInsuree.OtherNames, DOB = tblInsuree.Dob.ToString("yyyy-MM-dd"), IsHead = tblInsuree.IsHead, Phone = tblInsuree.Phone, Gender = tblInsuree.Gender, Marital = tblInsuree.Marital, TypeOfId = tblInsuree.TypeOfId, CardIssued = tblInsuree.CardIssued, Email = tblInsuree.Email, CurrentAddress = tblInsuree.CurrentAddress, GeoLocation = tblInsuree.GeoLocation, IdentificationTypes = tblInsuree.TypeOfId }; if (tblInsuree.Relationship != null) { insuree.Relationship = (short)tblInsuree.Relationship; } if (tblInsuree.Profession != null) { insuree.Profession = TypeCast.GetValue <short>(tblInsuree.Profession); } if (tblInsuree.Education != null) { insuree.Education = TypeCast.GetValue <short>(tblInsuree.Education); } if (tblInsuree.Hfid != null) { insuree.HFID = (short)tblInsuree.Hfid; } if (tblInsuree.CurrentVillage != null) { insuree.CurVillage = tblInsuree.CurrentVillage.ToString(); } if (tblInsuree.IsOffline != null) { insuree.IsOffline = (bool)tblInsuree.IsOffline; } if (tblInsuree.Photo != null) { insuree.PhotoPath = tblInsuree.Photo.PhotoFileName; } return(insuree); }