public MakeManagerTest() { _contextAccessor = new Mock <IHttpContextAccessor>(); var context = new DefaultHttpContext(); var token = TokenProvider.Instance.GetToken(Guid.NewGuid().ToString()); context.Request.Headers["Token"] = token; _contextAccessor.Setup(x => x.HttpContext).Returns(context); var mapperConfig = MapperConfig.CreateMapperConfig(); _makeManager = new MakeManager(mapperConfig.CreateMapper(), _contextAccessor.Object); _modelManager = new ModelManager(mapperConfig.CreateMapper(), _contextAccessor.Object); }
public MakesController(IMakeManager makeManager) { _makeManager = makeManager; }
public Seed(IDealerManager dealerManager, IMakeManager makeManager, IModelManager modelManager, ICarManager carManager, IFileManager fileManager, IHttpContextAccessor httpContextAccessor) { #if DEBUG _dealerManager = dealerManager; _makeManager = makeManager; _modelManager = modelManager; _carManager = carManager; _fileManager = fileManager; _httpContextAccessor = httpContextAccessor; // Generate cars for dealer 1 var dealer1 = _dealerManager.Add("Autohouse Motors"); _httpContextAccessor.HttpContext = new DefaultHttpContext(); _httpContextAccessor.HttpContext.Request.Headers["Token"] = TokenProvider.Instance.GetToken(dealer1.Id.ToString()); GenerateCars(dealer1.Id, "Mercedes-Benz", new Dictionary <string, IEnumerable <CarInputModel> >() { { "AMG", new List <CarInputModel>() { new CarInputModel() { Body = Enums.CarBody.Convertible, Color = "Red", Price = 69999.4, StockLevel = 12, Year = 1999, Photos = new List <string>() { //_fileManager.UploadFileFromBytes(Resources.AMG1, $"{nameof(Resources.AMG1)}.jpg").GetAwaiter().GetResult() } }, new CarInputModel() { Body = Enums.CarBody.Coupe, Color = "Blue", Price = 3000, StockLevel = 11, Year = 2016, Photos = new List <string>() { //_fileManager.UploadFileFromBytes(Resources.AMG2, $"{nameof(Resources.AMG2)}.jpg").GetAwaiter().GetResult() } }, new CarInputModel() { Body = Enums.CarBody.Hatch, Color = "Black", Price = 50000.5, StockLevel = 1, Year = 2018, Photos = new List <string>() { // _fileManager.UploadFileFromBytes(Resources.AMG3, $"{nameof(Resources.AMG3)}.jpg").GetAwaiter().GetResult() } }, } }, { "E-Class", new List <CarInputModel>() { new CarInputModel() { Body = Enums.CarBody.Sedan, Color = "Black", Price = 150000, StockLevel = 123, Year = 2010, Photos = new List <string>() { // _fileManager.UploadFileFromBytes(Resources.e_class, $"{nameof(Resources.e_class)}.jpg").GetAwaiter().GetResult() } } } }, { "GLK", new List <CarInputModel>() { new CarInputModel() { Body = Enums.CarBody.SUV, Color = "Yellow", Price = 80000, StockLevel = 0, Year = 2019, Photos = new List <string>() { // _fileManager.UploadFileFromBytes(Resources.GLK1, $"{nameof(Resources.GLK1)}.jpg").GetAwaiter().GetResult() } }, new CarInputModel() { Body = Enums.CarBody.Wagon, Color = "Blue", Price = 53010, StockLevel = 1, Year = 2018, Photos = new List <string>() { // _fileManager.UploadFileFromBytes(Resources.GLK2, $"{nameof(Resources.GLK2)}.jpg").GetAwaiter().GetResult() } } } } }); GenerateCars(dealer1.Id, "Tesla", new Dictionary <string, IEnumerable <CarInputModel> >() { { "Model 3", new List <CarInputModel>() { new CarInputModel() { Body = Enums.CarBody.Sedan, Color = "Yellow", Price = 80000, StockLevel = 0, Year = 2019, Photos = new List <string>() { // _fileManager.UploadFileFromBytes(Resources.model_3, $"{nameof(Resources.model_3)}.jpg").GetAwaiter().GetResult() } } } }, { "Model X", new List <CarInputModel>() { new CarInputModel() { Body = Enums.CarBody.SUV, Color = "Yellow", Price = 180000, StockLevel = 12, Year = 2019, Photos = new List <string>() { // _fileManager.UploadFileFromBytes(Resources.model_x1, $"{nameof(Resources.model_x1)}.jpg").GetAwaiter().GetResult() } }, new CarInputModel() { Body = Enums.CarBody.SUV, Color = "Red", Price = 153010, StockLevel = 3, Year = 2018, Photos = new List <string>() { // _fileManager.UploadFileFromBytes(Resources.model_x2, $"{nameof(Resources.model_x2)}.jpg").GetAwaiter().GetResult() } } } }, { "Model S", new List <CarInputModel>() { new CarInputModel() { Body = Enums.CarBody.Sedan, Color = "Red", Price = 130000, StockLevel = 0, Year = 2016, Photos = new List <string>() { // _fileManager.UploadFileFromBytes(Resources.model_s, $"{nameof(Resources.model_s)}.jpg").GetAwaiter().GetResult() } } } } }); //// Generate cars for dealer 2 var dealer2 = _dealerManager.Add("Melbourne City Toyota"); _httpContextAccessor.HttpContext.Request.Headers["Token"] = TokenProvider.Instance.GetToken(dealer2.Id.ToString()); GenerateCars(dealer2.Id, "Rolls-Royce", new Dictionary <string, IEnumerable <CarInputModel> >() { { "Dawn", new List <CarInputModel>() { new CarInputModel() { Body = Enums.CarBody.Sedan, Color = "Red", Price = 130000, StockLevel = 6, Year = 2015, Photos = new List <string>() { // _fileManager.UploadFileFromBytes(Resources.rolls_royce1, $"{nameof(Resources.rolls_royce1)}.jpg").GetAwaiter().GetResult() } } } }, { "Phantom", new List <CarInputModel>() { new CarInputModel() { Body = Enums.CarBody.SUV, Color = "Red", Price = 120000, StockLevel = 3, Year = 2016, Photos = new List <string>() { // _fileManager.UploadFileFromBytes(Resources.rolls_royce3, $"{nameof(Resources.rolls_royce3)}.jpg").GetAwaiter().GetResult() } } } }, { "Corniche", new List <CarInputModel>() { new CarInputModel() { Body = Enums.CarBody.Hatch, Color = "Blue", Price = 130000, StockLevel = 0, Year = 2018, Photos = new List <string>() { // _fileManager.UploadFileFromBytes(Resources.rolls_royce2, $"{nameof(Resources.rolls_royce2)}.jpg").GetAwaiter().GetResult() } } } } }); GenerateCars(dealer2.Id, "BMW", new Dictionary <string, IEnumerable <CarInputModel> >() { { "Mini", new List <CarInputModel>() { new CarInputModel() { Body = Enums.CarBody.Hatch, Color = "Red", Price = 50000, StockLevel = 10, Year = 2016, Photos = new List <string>() { // _fileManager.UploadFileFromBytes(GetResource(nameof(CarDealers.Properties.Resources.mini_cooper)), $"mini-cooper.jpg").GetAwaiter().GetResult() } } } } }); GenerateCars(dealer2.Id, "Toyota", new Dictionary <string, IEnumerable <CarInputModel> >() { { "REIZ", new List <CarInputModel>() } }); #endif }