public override async Task<object> ReadFromStreamAsync(Type type, Stream readStream, HttpContent content, IFormatterLogger formatterLogger)
        {
            var parts = await content.ReadAsMultipartAsync();
            var obj = Activator.CreateInstance(type);
            var propertiesFromObj = obj.GetType().GetRuntimeProperties().ToList();

            foreach (var property in propertiesFromObj.Where(x => x.PropertyType == typeof(FileModel)))
            {
                var file = parts.Contents.FirstOrDefault(x => x.Headers.ContentDisposition.Name.IndexOf(property.Name, StringComparison.InvariantCultureIgnoreCase) != -1);

                if (file == null || file.Headers.ContentLength <= 0) continue;

                try
                {
                    var fileModel = new FileModel(file.Headers.ContentDisposition.FileName.Trim('\"'), file.Headers.ContentType.MediaType, Convert.ToInt32(file.Headers.ContentLength), await file.ReadAsStreamAsync()); //(file.Headers.ContentDisposition.FileName, Convert.ToInt32(file.Headers.ContentLength), ReadFully(file.ReadAsStreamAsync().Result));
                    property.SetValue(obj, fileModel);
                }
                catch (Exception e)
                {
                }
            }

            foreach (var property in propertiesFromObj.Where(x => x.PropertyType != typeof(FileModel)))
            {
                var formData = parts.Contents.FirstOrDefault(x => x.Headers.ContentDisposition.Name.IndexOf(property.Name, StringComparison.InvariantCultureIgnoreCase) != -1);

                if (formData == null) continue;

                try
                {
                    var strValue = formData.ReadAsStringAsync().Result;
                    var valueType = Nullable.GetUnderlyingType(property.PropertyType) ?? property.PropertyType;
                    var value = Convert.ChangeType(strValue, valueType);
                    property.SetValue(obj, value);
                }
                catch (Exception e)
                {
                }
            }

            return obj;
        }
 public Dictionary<string, FaceRecognitionTrainingStatus> TrainFaceRecognition(FileModel zippedDirectory)
 {
     return _fromFileDatabaseFiller.ReadImagesWithPersonsFromZip(zippedDirectory);
 }
        public Dictionary<string, FaceRecognitionTrainingStatus> ReadImagesWithPersonsFromZip(FileModel zippedDirectory)
        {
            if (zippedDirectory != null && zippedDirectory.Content != null && ZipFile.IsZipFile(zippedDirectory.Content, false))
            {
                if (zippedDirectory.Content.CanSeek)
                {
                    zippedDirectory.Content.Seek(0, SeekOrigin.Begin);
                }

                string extractedPath = _tempDirectory + "\\" + Guid.NewGuid();

                if (!Directory.Exists(_tempDirectory))
                {
                    Directory.CreateDirectory(_tempDirectory);
                }

                using (var zipFile = ZipFile.Read(zippedDirectory.Content))
                {
                    zipFile.ExtractAll(extractedPath, ExtractExistingFileAction.OverwriteSilently);
                }

                var faceRecognitionTrainingStatuses = ReadImagesWithPersonsFromDirectory(extractedPath);

                Directory.Delete(extractedPath, true);

                return faceRecognitionTrainingStatuses;
                //zipFile.ExtractAll()
            }

            return null;
        }