Beispiel #1
0
        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);
            }
        }
Beispiel #2
0
        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"));
        }