예제 #1
0
        public async Task <IActionResult> RollenEintragen(IFormCollection Erg)
        {
            var lIdUsers = await _userManager.Users.ToListAsync();

            var idisIstAdmin    = (await _userManager.GetUsersInRoleAsync("Admin")).Select(s => s.Id).ToList();
            var idisIstAnwender = (await _userManager.GetUsersInRoleAsync("Auswertung")).Select(s => s.Id).ToList();

            var idisErgAdmin      = Erg.Where(w => (w.Key.Substring(0, 5) == "IdAdm")).Select(s => s.Key.Substring(5)).ToList();
            var idisErgAuswertung = Erg.Where(w => (w.Key.Substring(0, 5) == "IdAus")).Select(s => s.Key.Substring(5)).ToList();


            foreach (var user in lIdUsers)
            {
                if (!idisIstAdmin.Contains(user.Id) && idisErgAdmin.Contains(user.Id))
                {
                    await _userManager.AddToRoleAsync(user, "Admin");
                }
                else if (idisIstAdmin.Contains(user.Id) && !idisErgAdmin.Contains(user.Id))
                {
                    await _userManager.RemoveFromRoleAsync(user, "Admin");
                }

                if (!idisIstAnwender.Contains(user.Id) && idisErgAuswertung.Contains(user.Id))
                {
                    await _userManager.AddToRoleAsync(user, "Auswertung");
                }
                else if (idisIstAnwender.Contains(user.Id) && !idisErgAuswertung.Contains(user.Id))
                {
                    await _userManager.RemoveFromRoleAsync(user, "Auswertung");
                }
            }

            return(RedirectToAction("RollenEintragen"));
        }
        /// <summary>
        /// Update the feedback/response on Task.
        /// </summary>
        /// <returns>Details Page.</returns>
        /// <param name="s">Form values</param>
        public async Task <ActionResult> Comment(IFormCollection s)
        {
            if (!AuthenticationHelper.isAuthorizedUser(HttpContext.Session.GetString("Username")))
            {
                Response.Redirect("/Login");
            }

            //Fetch required data to create the feedback object
            int tid  = Convert.ToInt32(s.Where(ky => ky.Key == "TaskId").FirstOrDefault().Value);
            var task = _context.Tasks.Where(tsk => tsk.TaskId == tid).FirstOrDefault();
            var user = _context.Users.Where(usr => usr.Username == HttpContext.Session.GetString("Username")).FirstOrDefault();

            //Create Feedback object
            Feedback feedback = new Feedback();

            feedback.Response = s.Where(ky => ky.Key == "Response").FirstOrDefault().Value;
            feedback.TaskId   = task.TaskId;
            feedback.User     = user;
            feedback.Created  = DateTime.Now;

            _context.Feedbacks.Add(feedback);
            await _context.SaveChangesAsync();

            return(RedirectToAction("Details", new { id = tid }));
        }
예제 #3
0
        public static List <OrderDetails> GetOrderDetails(int orderId, IFormCollection formCollection)
        {
            int rowCounterInForm = int.Parse(formCollection.Where(c => c.Key == "rowCounter").FirstOrDefault().Value.ToString());
            var tmpCollection    = formCollection.Where(c => c.Key.ToString().Contains("input")).ToList();
            int rowCounter       = tmpCollection.Count / 6;       // 6 is the number of columns per row
            int itemCounter      = tmpCollection.Count / rowCounterInForm;
            int varControl       = 0;
            int switchControl    = 0;

            Console.Clear();
            List <OrderDetails> tmpOrderDetailsList = new List <OrderDetails>();

            for (int i = 0; i < (rowCounter); i++)
            {
                OrderDetails tmpOrderDetails = new OrderDetails();
                for (int j = varControl; j < (varControl + itemCounter); j++)
                {
                    Console.WriteLine($"Key: {tmpCollection[i + j].Key} - Value: {tmpCollection[i + j].Value}");
                    switch (j - varControl)
                    {
                    case 0:
                        tmpOrderDetails.Quantity = short.Parse(tmpCollection[i + j].Value);
                        break;

                    case 1:
                        tmpOrderDetails.ProductId = int.Parse(tmpCollection[i + j].Value);
                        break;

                    case 4:
                        tmpOrderDetails.UnitPrice = decimal.Parse(tmpCollection[i + j].Value);
                        break;

                    case 5:
                        tmpOrderDetails.Discount = float.Parse(tmpCollection[i + j].Value);
                        break;
                    }
                    switchControl = j;
                }

                Console.WriteLine();
                if (orderId > 0)
                {
                    tmpOrderDetails.OrderId = orderId;
                }

                tmpOrderDetailsList.Add(tmpOrderDetails);
                varControl = switchControl;
            }

            return(tmpOrderDetailsList);
        }
예제 #4
0
 public (bool result, string message) EditItem(IFormCollection form)
 {
     try
     {
         _client.Ado.BeginTran();
         var filter                  = form.Where(x => x.Key != "TableName" && x.Key != "Ids" && !string.IsNullOrWhiteSpace(x.Value)).ToArray();
         var ids                     = JsonConvert.DeserializeObject <JArray>(form["Ids"]);
         SugarParameter[] paras      = filter.Select(x => new SugarParameter(x.Key, x.Value)).ToArray();
         SugarParameter[] whereParas = ids.Select(x =>
         {
             if (x is JObject jo)
             {
                 return(new SugarParameter(jo.Properties().FirstOrDefault().Name, jo.Properties().FirstOrDefault().Value.ToString()));
             }
             return(null);
         }).Where(x => x != null).ToArray();
         string setString   = string.Join(',', paras.Select(x => $"`{x.ParameterName}`=@{x.ParameterName}"));
         string whereString = string.Join(" ", whereParas.Select(x => $"and `{x.ParameterName}`=@{x.ParameterName}")).Substring(3);
         string sql         = $"update `{form["TableName"]}` set {setString} where {whereString}";
         var    result      = _client.Ado.ExecuteCommand(sql, paras.Concat(whereParas).ToArray());
         _client.Ado.CommitTran();
         return(result > 0 ? (true, "数据修改成功!") : (false, "数据修改失败!"));
     }
     catch
     {
         _client.Ado.RollbackTran();
         return(false, "有些数据格式不正确,请确保所有数据的格式正确后重新提交!");
     }
 }
예제 #5
0
        public ActionResult Update(int __index, string __entityType, IFormCollection collection)
        {
            try
            {
                var entities = SelectAll(Type.GetType(__entityType));

                var entity = entities.ElementAt(__index);

                var excludedNames = new[] { "__RequestVerificationToken", "__entityType", "__index" };

                var values = collection
                             .Where(n => !string.IsNullOrWhiteSpace(n.Value.FirstOrDefault()))
                             .Where(n => !excludedNames.Contains(n.Key))
                             .ToDictionary(n => n.Key, n => (object)n.Value.FirstOrDefault());


                entity.InitializeWithConvert(values);

                entity.Commit();

                return(ShowTable(__entityType));
            }
            catch (Exception e)
            {
                ViewData["Message"] = e.Message;

                return(ShowTable(__entityType));
            }

            //return RedirectToAction(nameof(ShowTable));
        }
예제 #6
0
        public ActionResult Insert(string __entityType, IFormCollection collection)
        {
            try
            {
                var type = Type.GetType(__entityType);

                var entity = Instantiate(type);

                var excludedNames = new[] { "__RequestVerificationToken", "__entityType" };

                var values = collection
                             .Where(n => !string.IsNullOrWhiteSpace(n.Value.FirstOrDefault()))
                             .Where(n => !excludedNames.Contains(n.Key))
                             .ToDictionary(n => n.Key, n => (object)n.Value.FirstOrDefault());

                entity.InitializeWithConvert(values);

                entity.Commit();

                return(PrintTable(type));
            }
            catch (Exception e)
            {
                ViewData["Message"] = e.Message;

                return(ShowTable(__entityType));
            }
        }
예제 #7
0
        public static TResult ParseContentDelegate <TResult>(string key, IFormCollection formData,
                                                             Func <string, TResult> onStringNeedsBinding,
                                                             Func <IFormFile, TResult> onFileNeedsBinding,
                                                             Func <string, TResult> onFailure)
        {
            if (formData.IsDefaultOrNull())
            {
                return(onFailure("No form data provided"));
            }

            return(formData
                   .Where(kvp => kvp.Key == key)
                   .First(
                       (kvp, next) =>
            {
                var strValue = (string)kvp.Value;
                return onStringNeedsBinding(strValue);
            },
                       () =>
            {
                return formData.Files
                .Where(file => file.Name == key)
                .First(
                    (file, next) =>
                {
                    var strValue = (IFormFile)file;
                    return onFileNeedsBinding(strValue);
                },
                    () => onFailure("Key not found"));
            }));
        }
예제 #8
0
        public ActionResult Create(IFormCollection collection)
        {
            try
            {
                Client.Rating newRating = new Client.Rating();
                newRating.Comments     = collection.Where(x => x.Key.Equals("Comments")).Select(x => x.Value).FirstOrDefault();
                newRating.RatingTypeId = int.Parse(collection.Where(x => x.Key.Equals("RatingTypeId")).Select(x => x.Value).FirstOrDefault());
                newRating.CreatedDate  = DateTime.Now;

                // force waiting for the callback in order to see the results when moving to the list view
                _ = clientRating.PostRatingAsync(newRating).GetAwaiter().GetResult();

                return(RedirectToAction(nameof(Index)));
            }
            catch (Exception ex)
            {
                return(View());
            }
        }
        private static IDictionary ToDictionary(IFormCollection query, Func <string, bool> isFormFieldIgnored)
        {
            var dict = new Dictionary <string, string>();

            foreach (var value in query.Where(v => isFormFieldIgnored(v.Key) == false))
            {
                dict[value.Key] = string.Join(",", value.Value);
            }
            return(dict);
        }
        private void Parse(IFormCollection collection)
        {
            var formFields = collection.Where(kv => !string.IsNullOrWhiteSpace(kv.Value))
                             .ToDictionary(item => item.Key, item => item.Value.ToString());

            if (formFields.Any(InvalidField))
            {
                return;
            }

            Fields = formFields;
        }
        private Product MapFieldViewModels(ProductViewModel productViewModel, IFormCollection formCollection)
        {
            var fields = formCollection.Where(formPair => formPair.Key.Contains("characteristic"))
                         .Select(formPair => new Field
            {
                CharacteristicId = int.Parse(formPair.Key.Substring(formPair.Key.IndexOf('-') + 1)),
                Value            = formPair.Value
            });

            var product = _mapper.Map <ProductViewModel, Product>(productViewModel);

            product.Fields = fields;

            return(product);
        }
예제 #12
0
        public IActionResult DataUpload(IFormCollection formdata)
        {
            var dataFields   = formdata.Where(x => x.Key == "DataFields").Select(x => x.Value).First().ToString();
            var customField  = formdata.Where(x => x.Key == "CustomField").Select(x => x.Value).First().ToString();
            var dataMappings = formdata.Where(x => x.Key == "DataMapping").Select(x => x.Value).First().ToString();

            if (String.IsNullOrEmpty(customField))
            {
                BaseDataService dataService = new BaseDataService(_config);

                if (dataService.ValidateDataIntoStaging(dataFields))
                {
                    if (dataService.ApplyMappingsToStaging(dataMappings))
                    {
                        dataService.InsertintoOutputTable();
                    }
                }
            }
            else
            {
                CustomDataService dataService = new CustomDataService(_config);
                dataService.customSourceField = customField;
                dataService.ExtractionMethod  = ExtractFromCustomField;



                if (dataService.ValidateDataIntoStaging(dataFields))
                {
                    if (dataService.ApplyMappingsToStaging(dataMappings))
                    {
                        dataService.InsertintoOutputTable();
                    }
                }
            }
            return(View());
        }
예제 #13
0
 public (bool result, string message) AddItem(IFormCollection form)
 {
     try
     {
         var filter             = form.Where(x => x.Key != "TableName" && !string.IsNullOrWhiteSpace(x.Value)).ToArray();
         SugarParameter[] paras = filter.Select(x => new SugarParameter(x.Key, x.Value)).ToArray();
         string           sql   = $"insert into `{form["TableName"]}`({string.Join(',', filter.Select(x => $"`{x.Key}`"))}) values({string.Join(',', paras.Select(x => "@" + x.ParameterName))})";
         var result             = _client.Ado.ExecuteCommand(sql, paras);
         return(result > 0 ? (true, "数据新增成功!") : (false, "数据新增失败!"));
     }
     catch
     {
         return(false, "有些数据格式不正确,请确保所有数据的格式正确后重新提交!");
     }
 }
예제 #14
0
        private static bool CheckSignature(IFormCollection data)
        {
            if (!data.ContainsKey("api_sig"))
            {
                return(false);
            }

            string s = string.Join("", data.Where(x => x.Key != "api_sig" && x.Key != "format" && x.Key != "callback")
                                   .OrderBy(x => x.Key, StringComparer.Ordinal)
                                   .Select(x => x.Key + x.Value));

            s += "1a88014994509aeab650d46830ff7d7c";

            byte[] actualHash   = ToBytes(data["api_sig"].ToString());
            byte[] expectedHash = MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(s));

            return(actualHash.SequenceEqual(expectedHash));
        }
예제 #15
0
        public IActionResult Form(IFormCollection form)
        {
            try
            {
                if (form != null && form.Keys.Count > 0)
                {
                    var    entries = form.Where(x => x.Key != "formId").Select(x => string.Format("'{0}':'{1}'", x.Key, x.Value.ToString()));
                    string data    = "{" + string.Join(',', entries) + "}";
                    DataStore.Save(form["formId"], data);
                }

                return(RedirectToAction("ResultView"));
            }
            catch (Exception ex)
            {
                throw new HttpRequestException(ex.Message);
            }
        }
예제 #16
0
 public (bool result, string message, DataTable data) GetItemById(IFormCollection form)
 {
     try
     {
         var filter             = form.Where(x => x.Key != "TableName" && !string.IsNullOrWhiteSpace(x.Value)).ToArray();
         SugarParameter[] paras = filter.Select(x => new SugarParameter(x.Key, x.Value)).ToArray();
         DataTable        data  = _client.Ado.GetDataTable($"select * from {form["TableName"]} where 1=1 {string.Join(" ", paras.Select(x => $"and `{x.ParameterName}`=@{x.ParameterName}"))}", paras);
         if (data == null)
         {
             return(false, "没有找到你想要的数据!", null);
         }
         return(true, "获取数据成功!", data);
     }
     catch
     {
         return(false, "查询过程中出现了些错误!", null);
     }
 }
예제 #17
0
        // [ValidateAntiForgeryToken]
        public ActionResult Update(int __index, string __entityType, IFormCollection collection)
        {
            try
            {
                Console.WriteLine("A");
                var type = Type.GetType(__entityType);

                var entities = SelectAll(type);

                var entity = entities.ElementAt(__index);

                var excludedNames = new[] { "__RequestVerificationToken", "__entityType", "__index" };

                var values = collection
                             .Where(n => !string.IsNullOrWhiteSpace(n.Value.FirstOrDefault()))
                             .Where(n => !excludedNames.Contains(n.Key))
                             .ToDictionary(n => n.Key, n => (object)n.Value.FirstOrDefault());

                var fields = type.GetProperties()
                             .Where(n => (n.PropertyType.IsValueType || n.PropertyType == typeof(string)));

                foreach (var field in fields)
                {
                    var validTypeValue = Convert.ChangeType(values[field.Name], field.PropertyType);

                    field.SetValue(entity, validTypeValue);
                }

                context.Update(entity);

                context.SaveChanges();

                // return RedirectToAction("Index");
                return(ShowTable(__entityType));
            }
            catch (Exception e)
            {
                ViewData["Message"] = e.Message;

                return(ShowTable(__entityType));
            }
        }
        public IActionResult OnPost(AppUser appUserData, [FromForm] IFormCollection coll)
        {
            try
            {
                if (ModelState.IsValid != true)
                {
                    return(Page());
                }

                int roleId = int.Parse(coll.Where(x => x.Key == "AppRoleId").Select(x => x.Value).FirstOrDefault());

                m_Security.CreateAppUser(AppUserData, roleId);

                return(RedirectToPage(Navigator.CreateAppUser));
            }
            catch (Exception ex)
            {
                m_Log.CriticalEntry(User.Identity.Name, ex.ToString());
                throw;
            }
        }
예제 #19
0
 public Respuesta <String> InicializarModelo(IFormCollection entrada)
 {
     try
     {
         Imagen         = entrada.Files[0];
         Codigo         = entrada.Where(x => x.Key == "Codigo").Select(x => x.Value).First().ToString();
         Nombre         = entrada.Where(x => x.Key == "Nombre").Select(x => x.Value).First().ToString();
         Descripcion    = entrada.Where(x => x.Key == "Descripcion").Select(x => x.Value).First().ToString();
         Cantidad       = int.Parse(entrada.Where(x => x.Key == "Cantidad").Select(x => x.Value).First().ToString());
         CantidadMinima = int.Parse(entrada.Where(x => x.Key == "CantidadMinima").Select(x => x.Value).First().ToString());
         Categoria      = entrada.Where(x => x.Key == "Categoria").Select(x => x.Value).First().ToString();
         Valor          = int.Parse(entrada.Where(x => x.Key == "Valor").Select(x => x.Value).First().ToString());
         return(new Respuesta <string>("Todo correcto", false, 200));
     }
     catch (Exception e)
     {
         return(new Respuesta <string>($"Error al mapear el modelo: " + e.Message, 500));
     }
 }
        public IActionResult Index(IFormCollection form)
        {
            ConnectionSettings connectionSettings = new ConnectionSettings(new Uri("http://10.1.9.180:9200"));

            connectionSettings.DefaultIndex("product_pool");
            var mapping = this.client.Instance.GetMapping(new GetMappingRequest(Nest.Indices.Index("product_pool")));

            List <KeyValuePair <string, string> > FieldList = mapping.Indices.First().Value.Mappings.Values.First().Properties.Select(x => new KeyValuePair <string, string>(x.Key.Name, x.Value.Type))
                                                              .ToList();
            SearchDescriptor <Dictionary <string, object> > search = new SearchDescriptor <Dictionary <string, object> >();

            search = search.Index("product_pool");
            search = search.AllTypes();
            var qr = new QueryContainerDescriptor <Dictionary <string, object> >();

            QueryContainer queryContainer = new QueryContainer();

            foreach (var itePair in form.Where(x => !string.IsNullOrEmpty(x.Value)).ToList())
            {
                if (FieldList.Any(x => x.Key == itePair.Key.Replace("searchKey_", "")))
                {
                    queryContainer &= qr.Term(itePair.Key.Replace("searchKey_", ""), itePair.Value[0]);
                }
            }

            search.Query(descriptor => queryContainer);
            var documents = this.client.Instance.Search <Dictionary <string, object> >(search);

            //var documents = this.client.Instance.Search<Dictionary<string, object>>(new SearchRequest() { Query = queryContainer });

            //var documents = this.client.Instance.Search<Dictionary<string, object>>(x => x.Index("product_pool").AllTypes().MatchAll());
            var model = new SearchViewModel
            {
                Documents = documents.Hits.Select(x => x.Source).ToList(),
                FieldList = FieldList
            };

            return(View(model));
        }
 private static IDictionary ToDictionary(IFormCollection query, Func<string, bool> isFormFieldIgnored)
 {
   var dict = new Dictionary<string, string>();
   foreach (var value in query.Where(v => isFormFieldIgnored(v.Key) == false))
   {
     dict[value.Key] = string.Join(",", value.Value);
   }
   return dict;
 }
예제 #22
0
        public async Task <IActionResult> IdentityEditAsync(int id, Identity identityModel, IFormCollection collection)
        {
            using var ctrl = Factory.Create <Contract>(SessionWrapper.SessionToken);
            async Task <IActionResult> CreateFailedAsync(Identity identity, string error)
            {
                var entity = await ctrl.CreateAsync().ConfigureAwait(false);

                entity.Identity.CopyProperties(identity);

                var model = ConvertTo <Model, Contract>(entity);

                model.ActionError = error;
                await LoadRolesAsync(model).ConfigureAwait(false);

                return(View("Edit", model));
            }

            async Task <IActionResult> EditFailedAsync(Identity identity, string error)
            {
                var entity = await ctrl.GetByIdAsync(identity.Id).ConfigureAwait(false);

                entity.Identity.CopyProperties(identity);

                var model = ConvertTo <Model, Contract>(entity);

                model.ActionError = error;
                await LoadRolesAsync(model).ConfigureAwait(false);

                return(View("Edit", model));
            }

            async Task UpdateRolesAsync(Model model)
            {
                using var ctrlRole = Factory.Create <Contracts.Persistence.Account.IRole>(SessionWrapper.SessionToken);
                var roles = await ctrlRole.GetAllAsync().ConfigureAwait(false);

                model.ClearRoles();
                foreach (var item in collection.Where(l => l.Key.StartsWith("Assigned")))
                {
                    var roleId = item.Key.ToInt();
                    var role   = roles.SingleOrDefault(r => r.Id == roleId);

                    if (role != null)
                    {
                        model.AddRole(role);
                    }
                }
            }

            if (ModelState.IsValid == false)
            {
                if (identityModel.Id == 0)
                {
                    return(await CreateFailedAsync(identityModel, GetModelStateError()).ConfigureAwait(false));
                }
                else
                {
                    return(await EditFailedAsync(identityModel, GetModelStateError()).ConfigureAwait(false));
                }
            }
            try
            {
                if (identityModel.Id == 0)
                {
                    var entity = await ctrl.CreateAsync().ConfigureAwait(false);

                    entity.Identity.CopyProperties(identityModel);
                    var model = ConvertTo <Model, Contract>(entity);

                    await UpdateRolesAsync(model).ConfigureAwait(false);

                    var result = await ctrl.InsertAsync(model).ConfigureAwait(false);

                    id = result.Id;
                }
                else
                {
                    var entity = await ctrl.GetByIdAsync(id).ConfigureAwait(false);

                    var model = ConvertTo <Model, Contract>(entity);
                    model.Identity.CopyProperties(identityModel);
                    await UpdateRolesAsync(model).ConfigureAwait(false);

                    await ctrl.UpdateAsync(model).ConfigureAwait(false);
                }
            }
            catch (Exception ex)
            {
                if (identityModel.Id == 0)
                {
                    return(await CreateFailedAsync(identityModel, GetExceptionError(ex)).ConfigureAwait(false));
                }
                else
                {
                    return(await EditFailedAsync(identityModel, GetExceptionError(ex)).ConfigureAwait(false));
                }
            }
            return(RedirectToAction("Edit", new { id }));
        }
        public DataShell Validate(IQueryCollection requestParams, IFormCollection formData)
        {
            var result = new DataShell();

            if (!requestParams.ContainsKey("type") ||
                (requestParams.ContainsKey("type") &&
                 (requestParams["type"].ToString() != "article" &&
                  requestParams["type"].ToString() != "section")
                ) ||
                !formData.ContainsKey("JSON")
                )
            {
                result.error = "invalid query parametrs";
                return(result);
            }
            string jsonData = formData.Where(x => x.Key == "JSON")?.Select(x => x.Value.ToString()).FirstOrDefault();

            if (jsonData == null)
            {
                result.error = "invalid JSON parametrs";
                return(result);
            }

            switch (requestParams["type"].ToString())
            {
            case ("article"):
            {
                try
                {
                    ArticleBase updateArticleData = JsonConvert.DeserializeObject <ArticleBase>(jsonData);
                    result.error = updateArticleData.Validate().error;
                    result.data  = updateArticleData;
                }
                catch
                {
                    result.error = "invalid article data structure";
                    return(result);
                }
                break;
            }

            case ("section"):
            {
                try
                {
                    Section preSection = JsonConvert.DeserializeObject <Section>(jsonData);
                    result.error = preSection.Validate().error;
                    result.data  = preSection;
                }
                catch
                {
                    result.error = "invalid section data structure";
                    return(result);
                }
                break;
            }

            default:
            {
                result.error = "invalid query parametrs";
                return(result);
            }
            }
            return(result);
        }
예제 #24
0
        public void AddPropertiesToModel(IContent content, IFormCollection formCollection)
        {
            var modelType       = content.ModelType;
            var contentModel    = JsonConvert.DeserializeObject(content.ModelAsJson, modelType);
            var properties      = contentModel.GetType().GetProperties().Where(w => w.GetCustomAttribute <IgnorePropertyAttribute>() == null);
            var modelProperties = RecursiveModelProperties("", contentModel, null, formCollection);

            foreach (var propertyInfo in properties)
            {
                if (!propertyInfo.CanWrite)
                {
                    continue;
                }

                var isEnumerable = IsPropertyEnumerable(propertyInfo);
                var testProperty = modelProperties.FirstOrDefault(w => w.PropertyInfo == propertyInfo);
                if (testProperty != null)
                {
                    if (testProperty.IsComplexType)
                    {
                        if (testProperty.IsEnumerable)
                        {
                            var itemsType = testProperty.PropertyInfo.PropertyType.GenericTypeArguments.First();

                            var formGroups = formCollection.Keys.Where(w => w.StartsWith($"{testProperty.Name}["))
                                             .Select(w => w.Split('.').First()).Distinct().ToList();

                            var lst = new List <object>();
                            if (!formGroups.Any() && formCollection[testProperty.Name].Count > 0)
                            {
                                var converter = TypeDescriptor.GetConverter(itemsType);
                                lst.AddRange(formCollection[testProperty.Name].Where(key => !string.IsNullOrEmpty(key)).Select(key => converter.ConvertFrom(key)));
                            }
                            else
                            {
                                var itemProperties = itemsType.GetProperties().ToArray();
                                foreach (var key in formGroups)
                                {
                                    var formProperties = formCollection.Where(w => w.Key.StartsWith(key)).ToList();
                                    var subProperties  = RecursiveModelProperties($"{key}.{propertyInfo.Name}.", null,
                                                                                  null, new FormCollection(formProperties.ToDictionary(k => k.Key, v => v.Value)),
                                                                                  itemProperties);

                                    lst.Add(CreateTypedPropertyValue(subProperties, itemsType));
                                }
                            }

                            propertyInfo.SetValue(contentModel, ConvertValueToType(lst, propertyInfo.PropertyType));
                        }
                        else
                        {
                            var obj = CreateTypedPropertyValue(testProperty.Properties, propertyInfo.PropertyType);
                            propertyInfo.SetValue(contentModel, obj);
                        }
                    }
                    else
                    {
                        var value = testProperty.Value;
                        if (!formCollection.ContainsKey(testProperty.Name))
                        {
                            value = GetDefault(testProperty.Type);
                        }

                        propertyInfo.SetValue(contentModel, ConvertValueToType(propertyInfo, isEnumerable, value));
                    }
                }
            }

            content.ModelAsJson = JsonConvert.SerializeObject(contentModel);
        }