private static void SaveImagesInDB(Image userImage)
 {
     using (var db = new ImageContext())
     {
         try
         {
             db.Images.Add(userImage);
             db.SaveChanges();
         }
         catch (Exception ex)
         {
         }
     }
 }
        private void SaveResizedImagesInDB(Image userImage, ResizedImageInfo imageInfo)
        {
            using (var db = new ImageContext())
            {

                var ResizedImage = new ResizedImage()
                {
                    ParentId = userImage.Id,
                    FileName = imageInfo.FileName,
                    FilePath = Url.Content("~/Images/" + imageInfo.FileName),
                    PreviewPath = userImage.PreviewPath,
                    Height = imageInfo.Height,
                    Width = imageInfo.Width,
                    StartTime = imageInfo.StartTime,
                    FinishTime = imageInfo.FinishTime
                };

                try
                {
                    db.ResizedImages.Add(ResizedImage);
                    db.SaveChanges();
                    userImage.ResizedImages.Add(new ResizedImageWithPreview(ResizedImage));
                }
                catch (Exception ex)
                {

                }
            }
        }