public ActionResult Create(BreweryCreate model) { if (!ModelState.IsValid) { return(View(model)); } if (_service.CreateBrewery(model)) { TempData["SaveResult"] = "Brewery was added."; return(RedirectToAction("Index")); } ; ModelState.AddModelError("", "Brewery could not be created."); return(View(model)); }
public void Create_Correct_Brewery() { var options = Utils.GetOptions(nameof(Create_Correct_Brewery)); var brewery = new Brewery { Id = 1, Name = "Diamond Knot Brewery", Description = "America", CountryId = 1 }; using (var arrangeContext = new BeerOverflowContext(options)) { var sut = new BreweryService(arrangeContext); var breweryDTO = new BreweryDTO(brewery.Id, brewery.Name, brewery.Description, brewery.CountryId); var result = sut.CreateBrewery(breweryDTO); Assert.AreEqual(brewery.Id, result.Id); Assert.AreEqual(brewery.Name, result.Name); Assert.AreEqual(brewery.Description, result.Description); Assert.AreEqual(brewery.CountryId, result.CountryId); } }