/// <summary>
        /// Handles the Click event of the btnSave control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
        private async void btnSave_Click(object sender, RoutedEventArgs e)
        {
            ShowLock = true;

            var file = new PictureFile {
                DateAdded = DateTime.Now, FilePath = _selectedFilePath, IsConfirmed = true
            };

            _db.AddFile(file, _scanGroup.Group.LargePersonGroupId, 2);

            var newFacesForTraining = false;

            for (var ix = 0; ix < DetectedFaces.Count; ix++)
            {
                var face   = DetectedFaces[ix];
                var person = new PicturePerson
                {
                    DateAdded          = DateTime.Now,
                    PersonId           = face.PersonId,
                    PictureFileId      = file.Id,
                    LargePersonGroupId = _scanGroup.Group.LargePersonGroupId,
                    FaceJSON           = Newtonsoft.Json.JsonConvert.SerializeObject(face),
                    IsConfirmed        = true
                };
                _db.AddPerson(person);

                if (face.AddToGroup)
                {
                    var contentControl = face.ContextBinder.Parent as ContentControl;
                    var parentGrid     = contentControl.Parent as Grid;
                    var croppedImage   = parentGrid.Children[1] as Image;

                    var filePath = face.ImageFile.ToString().Replace("file:///", "");
                    filePath = filePath.Replace('\\', '/');

                    var fileName    = $"DbId-{person.Id}_" + System.IO.Path.GetFileName(filePath); // unique file name, into training folder
                    var newFilePath = System.IO.Path.Combine(face.PersonSourcePath, fileName);

                    CropToSquare(filePath, newFilePath, face.Left, face.Top, face.Width, face.Height);

                    await AddFaceToLargePersonGroup(_scanGroup.Group.LargePersonGroupId, newFilePath, face.PersonId);

                    newFacesForTraining = true;
                }
            }

            if (newFacesForTraining)
            {
                await CheckGroupIsTrained();
            }

            try
            {
                await GetNextFile();
            }
            catch (Exception exc)
            {
                MainWindow.Log("Error getting next file: " + exc.Message);
            }
        }
 public void AddPerson(PicturePerson person)
 {
     _db.PicturePersons.Add(person);
     _db.SaveChanges();
 }