Exemplo n.º 1
0
        public bool GenerateLocation(string s, IStoreRepository store, out bool exit)
        {
            exit = false;
            if (s.Equals("0", StringComparison.OrdinalIgnoreCase))
            {
                exit = true;
                return(false);
            }
            Location location = new Location(s, "", "", "", "", "", ""); // TODO: Console prompts for location info

            store.AddLocation(location);
            store.Save();
            return(true);
        }
Exemplo n.º 2
0
        public ActionResult Create(LocationViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                _logger.LogWarning($"Encountered error creating new location, returning to creation page at {DateTime.Now}");
                return(View(viewModel));
            }
            try {
                var location = new Location(viewModel.Name, viewModel.Address, viewModel.City, viewModel.State, viewModel.Country, viewModel.Zip, viewModel.Phone);

                _repository.AddLocation(location);
                _repository.Save();
                _logger.LogInformation($"Created new location, {location.Name}, at {DateTime.Now}");
                return(RedirectToAction(nameof(Index)));
            } catch {
                ModelState.AddModelError("", "Error creating new location.");
                _logger.LogWarning($"Encountered error creating new location, returning to creation page at {DateTime.Now}");
                return(View(viewModel));
            }
        }
Exemplo n.º 3
0
 public Location AddLocation(Location newLocation)
 {
     return(_repo.AddLocation(newLocation));
 }