public byte[] GetDistributorPhysicalProfile(Distributor distributor) { var profile = _profileRepository.TableNoTracking.IncludeTable(c => c.ProfileBox) .FirstOrDefault(c => c.DistNumber == distributor.DistributorNo && c.ProfileBox.TypeId == 1); if (profile == null) { throw new ABOException(_resourceManager.GetString("ProfileImageMerging.FailedToFindProfile")); } var filePath = Path.Combine(_appSettings.ProfileBoxFolder, profile.ProfileBox.Name + "\\" + profile.FileName); if (File.Exists(filePath)) { return(File.ReadAllBytes(filePath)); } throw new ABOException(string.Format(_resourceManager.GetString("ProfileImageMerging.ContractFileNotFound"), profile.FileName)); }
public ProspectAvatar[] GetImageByAdaNo(Distributor distributor, bool isReadOnly = true) { const string imgStatus = "A"; var avatars = new ProspectAvatar[2]; short numOfNoImg = 0; var repositoryTable = isReadOnly ? _prospectAvatarRepository.TableNoTracking : _prospectAvatarRepository.Table; if (!string.IsNullOrEmpty(distributor.ID1)) { avatars[0] = repositoryTable.FirstOrDefault(c => c.img_cmnd_id == distributor.ID1 && c.img_status == imgStatus); if (avatars[0] == null) { numOfNoImg++; } } if (!string.IsNullOrEmpty(distributor.ID2)) { avatars[1] = repositoryTable.FirstOrDefault(c => c.img_cmnd_id == distributor.ID2 && c.img_status == imgStatus); if (avatars[1] == null) { numOfNoImg++; } } if (numOfNoImg == 2) { throw new ABOException(_resourceManager.GetString("ProfileImageMerging.FailedToFindImages")); } return(avatars); }