コード例 #1
0
        public ActionResult Create(StoreViewModel viewStore)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    ModelState.AddModelError("", "Invalid input format");
                    return(View(viewStore));
                }

                // unfinished
                var newLocation = new CStore(viewStore.Storeloc, viewStore.Storephone, viewStore.Zipcode);
                _storeRepo.AddOneStore(newLocation);
                return(RedirectToAction(nameof(Index)));
            }
            catch (Exception e)
            {
                _logger.LogError(e, "error while tring to add a store");
                ModelState.AddModelError("", "failed to create a store");
                return(View());
            }
        }