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 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); }