public async Task <ActionResult> EditInDatabase(StoreViewModel storeViewModel) { if (!ModelState.IsValid) { storeViewModel.companies = await companyRepository.List(); return(View(storeViewModel)); } Stores store = StoreViewModelConverter.toStore(storeViewModel, new Stores()); storeRepository.Update(store); return(RedirectToAction("Index")); }
public async Task <ActionResult> Create(StoreViewModel storeViewModel) { if (!ModelState.IsValid) { storeViewModel.companies = await companyRepository.List(); return(View(storeViewModel)); } Stores storeToCreate = StoreViewModelConverter.toStore(storeViewModel, new Stores()); storeToCreate.Id = Guid.NewGuid(); await storeRepository.Create(storeToCreate); return(RedirectToAction("Index")); }