public ActionResult CreateItem(ItemViewModel model, string[] text, int[] fieldId) { if (ModelState.IsValid) { if (text != null) { for (int i = 0; i < text.Length; i++) { model.CustomValues.Add(new CustomValueViewModel() { CustomFieldId = fieldId[i], Value = text[i], ItemId = model.Id }); } } CollectionService.AddItem(model); } return(RedirectToAction($"Collection/{model.GroupId}")); }