/// <summary>
        /// Extracts the exif save.
        /// </summary>
        /// <param name="stream">The stream.</param>
        /// <param name="momento">The momento.</param>
        /// <returns>DateTime.</returns>
        public DateTime? ExtractExifSave(Stream stream, Momento momento)
        {
            DateTime? date = null;

            using (stream)
            {
                System.Drawing.Image image = System.Drawing.Image.FromStream(stream);
                PropertyItem[] items = image.PropertyItems;

                if (items.Length > 0)
                {
                    var exifs = new List<Exif>();

                    foreach (PropertyItem propertyItem in items)
                    {
                        //The below codes output funky strings that won't go into the database.
                        string[] ignore = { "501b", "5091", "5090", "927c" };
                        string id = propertyItem.Id.ToString("x");
                        string value = Encoding.UTF8.GetString(propertyItem.Value);

                        if (!ignore.Contains(id))
                        {
                            var exif = new Exif
                                {
                                    Momento = momento,
                                    Key = propertyItem.Id.ToString("x"),
                                    Type = propertyItem.Type,
                                    Value = string.IsNullOrWhiteSpace(value) ? string.Empty : value
                                };

                            exifs.Add(exif);
                        }

                        date = GetDate(id, value, date);
                    }

                        SaveExifs(exifs);

                }
            }

            return date;
        }
        /// <summary>
        /// Gets the image configurations.
        /// </summary>
        /// <param name="bytes">The bytes.</param>
        /// <param name="format">The format.</param>
        /// <param name="mediaMessage">The media message.</param>
        /// <param name="momento">The momento.</param>
        /// <returns>List{InParameters}.</returns>
        private IEnumerable<InParameters> GetImageConfigurations(byte[] bytes, ImageFormat format, Messaging.Models.Media mediaMessage, Momento momento)
        {
            return new List<InParameters>
            {
                new InParameters { Bytes = bytes, MomentoMediaType = MomentoMediaType.SmallImage, Format = format, MediaMessage = mediaMessage, MaxHeight = _settings.ImageSmallHeight, MaxWidth = _settings.ImageSmallWidth, Momento = momento},
                new InParameters { Bytes = bytes, MomentoMediaType = MomentoMediaType.MediumImage, Format = format, MediaMessage = mediaMessage, MaxHeight = _settings.ImageMediumHeight, MaxWidth = _settings.ImageMediumWidth, Momento = momento},
                new InParameters { Bytes = bytes, MomentoMediaType = MomentoMediaType.LargeImage, Format = format, MediaMessage = mediaMessage, MaxHeight = _settings.ImageLargeHeight, MaxWidth = _settings.ImageLargeWidth, Momento = momento},
                new InParameters { Bytes = bytes, MomentoMediaType = MomentoMediaType.OriginalImage, Format = format, MediaMessage = mediaMessage, MaxHeight = int.MaxValue, MaxWidth = int.MaxValue, Momento = momento},

            };
        }
        /// <summary>
        /// Saves the exif information.
        /// </summary>
        /// <param name="bytes">The bytes.</param>
        /// <param name="momento">The momento.</param>
        /// <param name="session">The session.</param>
        /// <returns>System.Nullable{DateTime}.</returns>
        private static DateTime? SaveExifInformation(byte[] bytes, Momento momento, ISession session)
        {
            var imageMetadata = new ExifData(session);
            DateTime? photoDateTime = imageMetadata.ExtractExifSave(new MemoryStream(bytes), momento);

            return photoDateTime;
        }
 /// <summary>
 /// Populates the momento object.
 /// </summary>
 /// <param name="mediaMessage">The media message.</param>
 /// <returns>Momento.</returns>
 private static Momento PopulateMomentoObject(Messaging.Models.Media mediaMessage)
 {
     var momento = new Momento
         {
             InternalId = mediaMessage.Id,
             User = new User {Username = mediaMessage.Username},
             UploadedBy = mediaMessage.Username,
             Visibility = "Public"
         };
     return momento;
 }
        /// <summary>
        /// Saves the automatic album.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="session">The session.</param>
        /// <param name="momento">The momento.</param>
        private static void SaveToAlbum(MediaMessage message, ISession session, Momento momento)
        {
            if (message.AlbumId.HasValue)
            {
                var album = session.Get<Album>(message.AlbumId);
                var albumMomento = new AlbumMomento {Album = album, Momento = momento};

                session.Save(albumMomento);
            }
        }
        /// <summary>
        ///     Saves the media.
        /// </summary>
        /// <param name="command">The command.</param>
        /// <param name="single">The single.</param>
        private void SaveMedia(CreateMomentoParameters command, Momento single)
        {
            command.Media.ForEach(m => m.MomentoId = single.Id);
            List<Schema.MomentoMedia> media =
                command.Media.ConvertAll(Mapper.DynamicMap<CreateMomentoMediaParameters, Schema.MomentoMedia>);

            using (ITransaction transaction = _session.BeginTransaction())
            {
                foreach (Schema.MomentoMedia momentoMedia in media)
                {
                    momentoMedia.Momento = single;
                    _session.Save(momentoMedia);
                }

                transaction.Commit();
            }
        }