public void SeedApps(IAddNewApp addNewApp) { for (int i = context.Apps.Count(); i < 5; i++) { var model = new AppModel { Name = $"App{i + 1}" }; addNewApp.Invoke(model); } }
public IActionResult Add(AppViewModel model) { if (!ModelState.IsValid) { Alert.Warning(); return(View(new FormModel <AppViewModel>(model, true))); } var newModel = new AppModel { Id = model.Id, Name = model.Name }; if (addNewApp.Invoke(newModel) != 0) { Alert.Success(); } else { Alert.Danger("Something went wrong"); } return(RedirectToAction("Index")); }