public async Task <ActionResult> Create(LanguageViewModel language) { if (ModelState.IsValid) { await _languageRepository.Create(language.Name); return(RedirectToAction(nameof(Index))); } return(View(language)); }
public void Should_save_new_language() { var newLanguage = LanguageFactory.Language(_siteId, Guid.NewGuid(), "Name", "CultureName", "Url"); using (var context = new MSSQLDbContext(_contextOptions)) { var repository = new LanguageRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper()); repository.Create(newLanguage); } using (var context = new MSSQLDbContext(_contextOptions)) { var repository = new LanguageRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper()); var language = repository.GetById(_siteId, newLanguage.Id); Assert.NotNull(language); } }