public Photo SavePhotoAndTags(Photo existingPhoto, string imageFilePath, string cacheFilePath, string checksum, ImageLayoutInfo imageLayoutInfo, IEnumerable <ExifDirectoryBase> exifDataList, params string[] tags) { _logger.LogInformation("Saving photo with checksum {Checksum}.", checksum); var dirTags = _fileSystemService.GetDirectoryTags(imageFilePath); var imageInfo = GetImageInfo(exifDataList); var photo = existingPhoto ?? new Photo(); photo.Name = Path.GetFileName(imageFilePath); photo.FileName = Path.GetFileName(cacheFilePath); photo.Checksum = checksum; photo.CacheFolder = Path.GetDirectoryName(cacheFilePath); photo.DateFileCreated = File.GetCreationTime(imageFilePath); photo.DateTaken = imageInfo.DateTaken; photo.ImageHeight = imageLayoutInfo.Height; photo.ImageWidth = imageLayoutInfo.Width; photo.ReprocessCache = false; _photoService.SavePhoto(photo); if (existingPhoto == null) { var photoTags = dirTags.ToList(); if (tags != null && tags.Length > 0) { photoTags.AddRange(tags); } _photoService.AssociateTags(photo, photoTags.ToArray()); } _logger.LogInformation("Saved photo to database."); return(photo); }