示例#1
0
        public async Task <IActionResult> Edit(int id, BreedFormModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            await this.breeds.EditAsync(
                id,
                model.Name,
                model.MinTankSize,
                model.ReefCompatible,
                model.CareLevel,
                model.Temperament,
                model.MaxSize,
                model.Diet,
                model.ImageUrl);

            return(RedirectToAction("All", "Breeds", new { area = string.Empty }));
        }
示例#2
0
        public async Task <IActionResult> Add(BreedFormModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            await this.breeds.AddBreedAsync(
                model.Name,
                model.MinTankSize,
                model.ReefCompatible,
                model.CareLevel,
                model.Temperament,
                model.MaxSize,
                model.Diet,
                model.ImageUrl);

            TempData.AddSuccessMessage($"Breed {model.Name} was successfully created.");
            return(RedirectToAction(nameof(AquariumsController.All), "Aquariums", new { area = string.Empty }));
        }