Beispiel #1
0
        public async Task <IActionResult> Edit(Guid id, CreateStoreViewModel createStoreViewModel)
        {
            Companies company = await _companiesService.FindBy(createStoreViewModel.Company.Id);

            createStoreViewModel.CompanyId = company.Id;

            if (ModelState.IsValid)
            {
                if (await _storesService.Edit(id, createStoreViewModel) != null)
                {
                    return(RedirectToAction(nameof(Index)));
                }
                ModelState.AddModelError("System", "Failed to edit");
            }

            return(View(createStoreViewModel));
        }
        public async Task <ActionResult> Edit(Store store)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    // TODO: Add insert logic here
                    await Service.Edit <Store>(store);

                    return(RedirectToAction("Index"));
                }

                return(View());
            }
            catch
            {
                return(View());
            }
        }