fixed download if no image return empty
This commit is contained in:
@@ -93,8 +93,42 @@ namespace FamilyTreeAPI.Repository
|
||||
Message = error
|
||||
};
|
||||
}
|
||||
public async Task<ResultModel<FileContent>> DownloadPersonPhotoById(int Id)
|
||||
{
|
||||
|
||||
public async Task<ResultModel<FileContent>> DownloadPersonPhoto(int personId, int photoType, string filename)
|
||||
int statusCode = -1;
|
||||
string error = "";
|
||||
string extension = "";
|
||||
PersonPhoto? model = null;
|
||||
FileContent fileContent = new();
|
||||
try {
|
||||
|
||||
model = await _context.PersonPhotos.FindAsync(Id);
|
||||
|
||||
|
||||
if (model != null)
|
||||
{
|
||||
extension = Helpers.GetFileExtension(model.Photo);
|
||||
fileContent.ContentType = Helpers.GetFileContent(extension);
|
||||
fileContent.Content = (byte[])model.ImagePhoto;
|
||||
fileContent.FileName = model.Photo;
|
||||
statusCode = 1;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
error = e.ToString();
|
||||
statusCode = -1;
|
||||
}
|
||||
return new ResultModel<FileContent>()
|
||||
{
|
||||
Data = fileContent,
|
||||
StatusCode = statusCode,
|
||||
Message = error
|
||||
};
|
||||
}
|
||||
|
||||
public async Task<ResultModel<FileContent>> DownloadPersonPhotoPerson(int personId, int photoType, string filename)
|
||||
{
|
||||
|
||||
int statusCode = -1;
|
||||
|
||||
Reference in New Issue
Block a user