public IActionResult CategoriesRegistry(int id) { var registryItems = db.RegistryItems.Where(x => x.RegistryId == id).ToList(); List <Item> items = new List <Item>(); foreach (var item in registryItems) { var currentItem = db.Items.FirstOrDefault(x => x.Id == item.ItemId); if (currentItem.Description.Length >= 132) { item.Item.Description = item.Item.Description.Substring(0, 123); item.Item.Description += " . . "; } items.Add(currentItem); } CategoriesRegistryViewModel categoriesRegistryViewModel = new CategoriesRegistryViewModel { Items = items, RegistryId = id }; if (registryItems.Count > 0) { categoriesRegistryViewModel.AccountId = db.Registries.FirstOrDefault(x => x.Id == registryItems[0].RegistryId).AccountId; } return(View(categoriesRegistryViewModel)); }
public IActionResult CategoriesRegistry(CategoriesRegistryViewModel categoriesRegistryViewModel, int id) { return(RedirectToAction("PreviewRegistryItems", new { id = id })); }