Exemplo n.º 1
0
        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"));
        }
Exemplo n.º 2
0
        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"));
        }