public void TestLocationRepo_CheckRepo() { var locationRepo = new LocationRepo(TripLineConfig.LocationRepoPath + "2", forceNew: true); Assert.IsTrue(locationRepo.Content.Locations.Count == 0); locationRepo.Add(new Location() { City = "Montreal" }); locationRepo.Save(); Assert.IsTrue(locationRepo.Content.Locations.Count == 1); locationRepo.ClearContent(); Assert.IsTrue(locationRepo.Content.Locations.Count == 0); // reload to see iuf they are really saved locationRepo.Reload(); // Check Assert.IsTrue(locationRepo.Content.Locations.Count == 1); Assert.IsTrue(locationRepo.Content.Locations[0].City == "Montreal"); }
public async Task <ActionResult> CreateLocation(CreateLocationViewModel model) { var locationRepository = new LocationRepo(); var orderRepository = new OrderRepo(); var customerRepository = new CustomerRepo(); var userId = User.Identity.GetUserId(); var location = new Models.Location { Title = model.Title, SecondTitle = model.SecondTitle, Customer = model.Customer, }; var order = new Order { LocationId = location.LocationId, UserId = userId }; location.UsersId.Add(userId); var testCustIds = await customerRepository.GetAllAsync(); await locationRepository.AddAsync(location); await orderRepository.AddAsync(order); return(RedirectToAction("Index", "Home", new { area = "" })); }
public IActionResult OnPost() { if (!ModelState.IsValid) { return(Page()); } int randomSpeed = random.Next(-20, 375); Location location = LocationRepo.GetLocation(LocationId); try { _speedMeasurementRepo.AddSpeedMeasurement(randomSpeed, location, MockData.RandomImage); } catch (CalibrationException cex) { CreateOtionsList(); InfoText = $"Error. The camera must be calibrated contact the support department or try again! {cex.Message}"; return(Page()); } catch (ArgumentException aex) { CreateOtionsList(); InfoText = $"Error. The camera must be calibrated contact the support department or try again! {aex.Message}"; return(Page()); } catch (Exception ex) { InfoText = $"Error. Something went wrong!Contact the support department {ex.Message}"; CreateOtionsList(); return(Page()); } return(RedirectToPage("Index")); }
public UnitOfWork(CPContext context) { _context = context; Customers = new CustomerRepo(_context); Events = new EventRepo(_context); Locations = new LocationRepo(_context); }
public MapController() { IUserContext IUContext = new UserMSSQLContext(); ILocationContext ILContext = new LocationMSSQLContext(); userRepo = new UserRepo(IUContext); locationRepo = new LocationRepo(ILContext); }
public void CreateOtionsList() { Options = LocationRepo.GetAllLocations().Select(a => new SelectListItem { Value = a.Id.ToString(), Text = a.Address }).ToList(); }
public PictureExifInformationTests() { _cut = new PictureExifInformationReader(); _googleClient = new GoogleClient(); _locationRepo = new LocationRepo(TripLineConfig.LocationRepoPath, forceNew: true); _placeRepo = new PlaceRepo(TripLineConfig.PlaceRepoPath); _locationService = new LocationService(_googleClient, _locationRepo, _placeRepo); _localFileFolder = new LocalFileFolders(_cut); }
public LocationServiceTests() { _exifReader = new PictureExifInformationReader(); _googleClient = new GoogleClient(); _locationRepo = new LocationRepo(TripLineConfig.LocationRepoPath, forceNew: false); _placeRepo = new PlaceRepo(TripLineConfig.PlaceRepoPath); _locationService = new LocationService(_googleClient, _locationRepo, _placeRepo); _localFileFolder = new LocalFileFolders(_exifReader); _photoStore = new PhotoStore(new PhotoRepo(forceNew: false), _localFileFolder, _locationService); }
public TripCreationServiceTests() { _googleClient = new GoogleClient(); _locationRepo = new LocationRepo(TripLineConfig.LocationRepoPath, forceNew: true); _placeRepo = new PlaceRepo(TripLineConfig.PlaceRepoPath); _locationService = new LocationService(_googleClient, _locationRepo, _placeRepo); _pictureExifReader = new PictureExifInformationReader(); _localFileFolder = new LocalFileFolders(_pictureExifReader); _photoStore = new PhotoStore(new PhotoRepo(), _localFileFolder, _locationService); _tripSmartBuilder = new TripSmartBuilder(_locationService, _photoStore, new DestinationBuilder(_locationService)); _tripStore = new TripStore(_photoStore, _locationService, _tripSmartBuilder, new TripsRepo()); }
private async Task <IEnumerable <Location> > GetLocations(string userId) { var orders = new OrderRepo(); var orderList = await orders.GetOrdersForUserAsync(userId); var loc = new LocationRepo(); var locationList = new List <Location>(); foreach (var v in orderList) { locationList.Add(loc.GetOne(v.LocationId)); } return(locationList); }
public void TestCheckLocationExistsFalse() { // Arrange var optionsBuilder = new DbContextOptionsBuilder <Project1Context>(); optionsBuilder.UseSqlServer(SecretConfiguration.ConnectionString); var options = optionsBuilder.Options; using (var dbContext = new Project1Context(options)) { ILocationRepo p0Repo = new LocationRepo(dbContext); // Act and Assert Assert.False(p0Repo.CheckLocationExists(100000)); } }
public void TestCheckLocationExistsTrue() { // Arrange var optionsBuilder = new DbContextOptionsBuilder <Project1Context>(); optionsBuilder.UseSqlServer(SecretConfiguration.ConnectionString); var options = optionsBuilder.Options; using (var dbContext = new Project1Context(options)) { ILocationRepo p0Repo = new LocationRepo(dbContext); var locations = p0Repo.GetAllLocations(); // Act and Assert Assert.True(p0Repo.CheckLocationExists(locations.ToList().First().Id)); } }
public object GetWeather(int locationId) { string responseString = CacheRepo.GetResponseFromLastFiveMinutesByLocationId(locationId); if (string.IsNullOrEmpty(responseString)) { var location = LocationRepo.GetLocationById(locationId); var client = new RestClient("http://api.openweathermap.org/data/2.5/"); var request = new RestRequest("forecast?zip=" + location.Zipcode + ",us&appid=" + APPID + "&units=imperial"); var response = client.Execute(request); responseString = response.Content; CacheRepo.SaveResponse(responseString, locationId); } var responseObject = JsonConvert.DeserializeObject <object>(responseString); return(responseObject); }
public HighliteTests() { ServiceBootStrapper.Configure(); _googleClient = new GoogleClient(); _locationRepo = new LocationRepo(TripLineConfig.LocationRepoPath); _placeRepo = new PlaceRepo(TripLineConfig.PlaceRepoPath); _locationService = new LocationService(_googleClient, _locationRepo, _placeRepo); _pictureExifReader = new PictureExifInformationReader(); _localFileFolder = new LocalFileFolders(_pictureExifReader); _photoStore = new PhotoStore(new PhotoRepo(forceNew: false), _localFileFolder, _locationService); _tripSmartBuilder = new TripSmartBuilder(_locationService, _photoStore, new DestinationBuilder(_locationService)); _tripStore = new TripStore(_photoStore, _locationService, _tripSmartBuilder, new TripsRepo(forceNew: false)); _highliteService = new HighliteService(_photoStore, _tripStore, _locationService); var tripCreationService = new TripCreationService(_tripStore, _photoStore, _locationService); var result = tripCreationService.Build(); if (result.NumNewTrips > 0) { tripCreationService.AddAll(); } }
public PizzaStoreRepository(project0Context db) { locationRepo = new LocationRepo(db) ?? throw new ArgumentNullException(nameof(db)); }
public LocationController(LocationRepo repo) { Repo = repo; }
public LocationList(LocationRepo repo) { this.repo = repo; }
public OrderController(OrderRepo repo, UserRepo userRepo, LocationRepo locationRepo) { Repo = repo; UserRepo = userRepo; LocRepo = locationRepo; }
public void DeleteById(int locationId) { LocationRepo.DeleteLocation(locationId); }
public void Create(Location location) { LocationRepo.AddLocation(location); }
public List <Location> GetByName(string name) { return(LocationRepo.GetLocationsByName(name)); }
static void Main(string[] args) { logger.Info("Beginning data retrieval"); var configBuilder = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true); IConfigurationRoot configuration = configBuilder.Build(); var optionsBuilder = new DbContextOptionsBuilder <Project1PizzaApplicationContext>(); optionsBuilder.UseSqlServer(configuration.GetConnectionString("Project1PizzaApplication")); logger.Info("Creating repo objects"); var userRepo = new UserRepo(new Project1PizzaApplicationContext(optionsBuilder.Options)); var locationRepo = new LocationRepo(new Project1PizzaApplicationContext(optionsBuilder.Options)); var orderRepo = new OrderRepo(new Project1PizzaApplicationContext(optionsBuilder.Options)); logger.Info("Repo objects created"); logger.Info("Beginning application"); User CurrentUser = new User(); Location Reston = new Location("Reston"); Location Herndon = new Location("Herndon"); Location Dulles = new Location("Dulles"); Location Hattontown = new Location("Hattontown"); int NumPizzas; logger.Info("Obtaining information from database"); var UserList = userRepo.GetUsers(); var LocationList = locationRepo.GetLocations(); var OrderList = orderRepo.GetOrders(); logger.Info("Information obtained"); logger.Info("Setting location information"); foreach (var item in LocationList) { if (item.CityName.ToLower() == "reston") { Reston = Mapper.Map(item); } if (item.CityName.ToLower() == "herndon") { Herndon = Mapper.Map(item); } if (item.CityName.ToLower() == "hattontown") { Hattontown = Mapper.Map(item); } if (item.CityName.ToLower() == "dulles") { Dulles = Mapper.Map(item); } } logger.Info("Setting location order history"); foreach (var item in OrderList) { if (item.StoreLocation.ToLower() == "reston") { Reston.OrderHistory.Add(Mapper.Map(item)); } if (item.StoreLocation.ToLower() == "herndon") { Herndon.OrderHistory.Add(Mapper.Map(item)); } if (item.StoreLocation.ToLower() == "hattontown") { Hattontown.OrderHistory.Add(Mapper.Map(item)); } if (item.StoreLocation.ToLower() == "dulles") { Dulles.OrderHistory.Add(Mapper.Map(item)); } } logger.Info("All information obtained and set"); Console.WriteLine("Welcome to our new pizza application!"); string Input; bool UsernameEntered = false; while (!UsernameEntered) { Console.WriteLine("Please enter a valid username, type 'users' to see all current users, or enter 'new'"); logger.Info("Obtaining username"); Input = Console.ReadLine(); Input = Input.ToLower(); if (Input.Equals("new")) { logger.Info("Creating New User"); CurrentUser = CreateNewUser(UserList, userRepo); logger.Info("New User Created"); UsernameEntered = true; Console.Clear(); } else if (UserList.Any(u => u.Username.ToLower() == Input)) { logger.Info("Retrieving user information"); foreach (var item in UserList) { if (item.Username.ToLower() == Input) { CurrentUser = Mapper.Map(item); } } logger.Info("User information retrieved"); UsernameEntered = true; Console.Clear(); } else if (Input.Equals("users")) { logger.Info("Listing current users"); ViewCurrentUsers(UserList); logger.Info("Users listed"); } else { Console.WriteLine("Username not detected."); } } bool KeepOpen = true; while (KeepOpen) { Console.WriteLine("Welcome! Let's get started!"); Console.WriteLine("Please input one of the following:"); Console.WriteLine("Order: place a new order; History: view your order history; Exit: exit the application"); logger.Info("Recieving use input"); Input = Console.ReadLine(); Input = Input.ToLower(); if (!Input.Equals("order") && !Input.Equals("exit") && !Input.Equals("history") && !Input.Equals("resupply")) { Console.WriteLine("Please input an accepted command"); Console.WriteLine("Order: place a new order; History : view your order history; Exit: exit the application"); Input = Console.ReadLine(); Input = Input.ToLower(); } else if (Input.Equals("order")) { logger.Info("Order selected"); Console.Clear(); Console.WriteLine("How many pizzas would you like to order (max of 12)? Please input a number."); Input = Console.ReadLine(); try { NumPizzas = int.Parse(Input); } catch (Exception ex) { Console.WriteLine("Error: Input was not an integer. Please input a number."); continue; } if (NumPizzas < 0) { Console.WriteLine("Error: Invalid input detected (we can't make negative pizzas)"); Console.WriteLine("Let's try this again from the top."); } else if (NumPizzas == 0) { Console.WriteLine("Wait...didn't you want to order at least one pizza? We have to start over..."); } else if (NumPizzas > 0 && NumPizzas <= 12) { logger.Info("Beginning order creation"); Console.WriteLine("Are we delivering from your favorite store? Y/N"); Console.WriteLine("Your favorite store is: " + CurrentUser.Favorite); Input = Console.ReadLine().ToLower(); bool ValidLocation = false; bool AcceptedInput = false; string DeliveryLocation = ""; if (Input != "y" && Input != "n") { while (!AcceptedInput) { Console.WriteLine("Please input either 'y' for yes or 'n' for no."); Input = Console.ReadLine().ToLower(); if (Input == "y" && Input == "n") { AcceptedInput = true; } } } if (Input == "n") { while (!ValidLocation) { Console.WriteLine("Which location shall we send the order to?"); Console.WriteLine("Valid locations: Reston, Herndon, Dulles, Hattontown"); DeliveryLocation = Console.ReadLine().ToLower(); if (DeliveryLocation != "reston" && DeliveryLocation != "herndon" && DeliveryLocation != "dulles" && DeliveryLocation != "hattontown") { Console.WriteLine("Please input a valid location."); } else { ValidLocation = true; } } } if (Input == "y") { DeliveryLocation = CurrentUser.Favorite; DeliveryLocation.ToLower(); } Order CurrentOrder = new Order(); bool CanOrder = true; logger.Info("Checking if user ordered more than 2 hours ago"); switch (DeliveryLocation) { case "reston": CanOrder = Reston.LastOrderOverTwoHoursAgo(CurrentUser); if (CanOrder) { CurrentOrder = Reston.CreateOrder(CurrentUser, NumPizzas); } break; case "herndon": CanOrder = Herndon.LastOrderOverTwoHoursAgo(CurrentUser); if (CanOrder) { CurrentOrder = Herndon.CreateOrder(CurrentUser, NumPizzas); } break; case "dulles": CanOrder = Dulles.LastOrderOverTwoHoursAgo(CurrentUser); if (CanOrder) { CurrentOrder = Dulles.CreateOrder(CurrentUser, NumPizzas); } break; case "hattontown": CanOrder = Hattontown.LastOrderOverTwoHoursAgo(CurrentUser); if (CanOrder) { CurrentOrder = Hattontown.CreateOrder(CurrentUser, NumPizzas); } break; default: break; } logger.Info("Check complete"); if (CanOrder) { logger.Info("Creating order"); CurrentUser.UserFavoritePizza(CurrentOrder); orderRepo.AddOrder(CurrentOrder); Console.Clear(); Console.WriteLine("Your order has been placed!"); Console.WriteLine(""); logger.Info("Order placed"); } else { Console.Clear(); Console.WriteLine("We're sorry, but you have already placed an order at this location within the past two hours."); Console.WriteLine("Please begin the order again selecting another location or wait two hours"); Console.WriteLine(""); logger.Info("User unable to order from chosen location"); } } else { Console.WriteLine("Error: There is a 12 pizza maximum. Please input a lower number of pizzas."); Console.WriteLine("We're going to have to start over..."); logger.Info("User attempted to go over pizza limit"); } } else if (Input.Equals("history")) { Console.Clear(); Console.WriteLine("How would you like the information displayed?"); Console.WriteLine("We can sort by: earliest, latest, cheapest, most expensive."); Console.WriteLine("Type '1' for earliest, '2' for latest, '3' for cheapest, or '4' for most expensive."); string Sort = Console.ReadLine(); Console.WriteLine(""); logger.Info("Displaying order history for user"); List <Order> UserOrderHistory = new List <Order>(); dynamic SortedHistory = ""; UserOrderHistory.AddRange(DisplayUserOrderHistory(CurrentUser, Sort, Reston)); UserOrderHistory.AddRange(DisplayUserOrderHistory(CurrentUser, Sort, Herndon)); UserOrderHistory.AddRange(DisplayUserOrderHistory(CurrentUser, Sort, Dulles)); UserOrderHistory.AddRange(DisplayUserOrderHistory(CurrentUser, Sort, Hattontown)); switch (Sort) { case "1": SortedHistory = UserOrderHistory.OrderBy(x => x.OrderPlaced).Select(x => x); break; case "2": SortedHistory = UserOrderHistory.OrderByDescending(x => x.OrderPlaced).Select(x => x); break; case "3": SortedHistory = UserOrderHistory.OrderBy(x => x.cost); break; case "4": SortedHistory = UserOrderHistory.OrderByDescending(x => x.cost); break; default: break; } foreach (var item in SortedHistory) { Console.WriteLine(item.OrderPlaced + " Total cost: $" + item.cost + ".00 Total pizzas:" + item.NumberOfPizzas + " from our " + item.location + " location."); Console.WriteLine("You ordered:"); Console.WriteLine(""); for (int i = 0; i < item.NumberOfPizzas; i++) { Console.WriteLine(" " + item.PrintPizza(item.DesiredSizes[i], item.DesiredTypes[i])); } Console.WriteLine(""); } logger.Info("History displayed"); } else if (Input.Equals("resupply")) { logger.Info("Resupplying location"); Console.Clear(); Console.WriteLine("Which store shall we resupply?"); Console.WriteLine("Enter 'Reston', 'Herndon', 'Dulles', or 'Hattontown'."); string ResupplyLoc = Console.ReadLine().ToLower(); switch (ResupplyLoc) { case "reston": Reston.Resupply(); break; case "herndon": Herndon.Resupply(); break; case "dulles": Dulles.Resupply(); break; case "hattontown": Hattontown.Resupply(); break; default: break; } } else if (Input.Equals("exit")) { KeepOpen = false; } } logger.Info("Updating user favorite pizza"); foreach (var item in UserList) { if (item.Username == CurrentUser.Username) { item.RecommendedPizza = CurrentUser.FavoritePizza; item.NumCheeseOrdered = CurrentUser.CheeseOrdered; item.NumPepperoniOrdered = CurrentUser.PepperoniOrdered; item.NumMeatOrdered = CurrentUser.MeatOrdered; item.NumVeggieOrdered = CurrentUser.VeggieOrdered; userRepo.UpdateUser(item); } } logger.Info("Update complete"); logger.Info("Updating location inventories"); foreach (var item in LocationList) { if (item.CityName.ToLower() == "reston") { item.DoughRemaining = Reston.Dough; item.SauceRemaining = Reston.Sauce; item.CheeseRemaining = Reston.Cheese; item.PepperoniRemaining = Reston.Pepperoni; item.MeatRemaining = Reston.HamAndMeatball; item.VeggiesRemaining = Reston.PeppersAndOnions; locationRepo.EditLocation(item); } if (item.CityName.ToLower() == "herndon") { item.DoughRemaining = Herndon.Dough; item.SauceRemaining = Herndon.Sauce; item.CheeseRemaining = Herndon.Cheese; item.PepperoniRemaining = Herndon.Pepperoni; item.MeatRemaining = Herndon.HamAndMeatball; item.VeggiesRemaining = Herndon.PeppersAndOnions; locationRepo.EditLocation(item); } if (item.CityName.ToLower() == "hattontown") { item.DoughRemaining = Hattontown.Dough; item.SauceRemaining = Hattontown.Sauce; item.CheeseRemaining = Hattontown.Cheese; item.PepperoniRemaining = Hattontown.Pepperoni; item.MeatRemaining = Hattontown.HamAndMeatball; item.VeggiesRemaining = Hattontown.PeppersAndOnions; locationRepo.EditLocation(item); } if (item.CityName.ToLower() == "dulles") { item.DoughRemaining = Dulles.Dough; item.SauceRemaining = Dulles.Sauce; item.CheeseRemaining = Dulles.Cheese; item.PepperoniRemaining = Dulles.Pepperoni; item.MeatRemaining = Dulles.HamAndMeatball; item.VeggiesRemaining = Dulles.PeppersAndOnions; locationRepo.EditLocation(item); } } logger.Info("update complete, closing application"); Environment.Exit(0); }
public LocationService(LocationRepo repo) { this.repo = repo; }
public LocationServImpl() { locationRepo = Factory.getInstance().getLocationRepo(); }
public Location GetByZip(string zip) { return(LocationRepo.GetLocationByZip(zip)); }
public LocationsController(LocationRepo locationRepo) { _locationRepo = locationRepo; }
public Provider() { LocationRepository = new LocationRepo(); CarRepository = new CarRepo(); }