/// Action generator
 /// @todo Implement lookup table or a design pattern for easier/automatic function generation
 public void actionGenerator( List<GameObject[]> combinations )
 {
     iThinkAction action;
     //printEverything(combinations);
     foreach ( GameObject[] matrix in combinations )
     {
       			switch ( schemaElements[0] )
         {
             case "get" :
                 action = new Get( "Get", matrix[0], matrix[1] );
                 tempActionList.Add(action);
                 break;
             case "buy" :
                 action = new Buy( "Buy", matrix[0], matrix[1], matrix[2] );
                 tempActionList.Add(action);
                 break;
             case "store" :
                 action = new Store( "Store", matrix[0], matrix[1]);
                 tempActionList.Add(action);
                 break;
             case "hunt" :
                 action = new Hunt( "Hunt", matrix[0], matrix[1], matrix[2], matrix[3]);
                 tempActionList.Add(action);
                 break;
             case "make" :
                 action = new Make( "Make", matrix[0], matrix[1], matrix[2]);
                 tempActionList.Add(action);
                 break;
             case "harvest" :
                 action = new Harvest( "Harvest", matrix[0], matrix[1], matrix[2]);
                 tempActionList.Add(action);
                 break;
             case "produce" :
                 action = new Produce( "Produce", matrix[0], matrix[1], matrix[2]);
                 tempActionList.Add(action);
                 break;
             case "craftSpell" :
                 action = new CraftSpell ("CraftSpell", matrix[0], matrix[1], matrix[2]);
                 tempActionList.Add(action);
                 break;
             case "craftSimpleWeapon" :
                 action = new CraftSimpleWeapon("CraftSimpleWeapon", matrix[0], matrix[1], matrix[2]);
                 tempActionList.Add(action);
                 break;
         }
     }
 }
Пример #2
0
        public void Dumper_TempTest()
        {
            var fiat = new Make { Name = "Fiat" };
            var panda = new Model { Name = "Panda" };
            var doblo = new Model { Name = "Doblo" };

            var renault = new Make { Name = "Renault" };
            var megane = new Model { Name = "Megane" };
            var clio = new Model { Name = "Clio" };

            var listings = new List<Listing>()
            {
                new Listing { Make = fiat, Model = panda, Year = 2010, Price = 1000 },
                new Listing { Make = fiat, Model = panda, Year = 2010, Price = 2000 },
                new Listing { Make = fiat, Model = panda, Year = 2011, Price = 3000 },
                new Listing { Make = fiat, Model = panda, Year = 2011, Price = 4000 },
                new Listing { Make = fiat, Model = panda, Year = 2013, Price = 5000 },

                new Listing { Make = fiat, Model = doblo, Year = 2007, Price = 1500 },
                new Listing { Make = fiat, Model = doblo, Year = 2008, Price = 2500 },
                new Listing { Make = fiat, Model = doblo, Year = 2009, Price = 3500 },
                new Listing { Make = fiat, Model = doblo, Year = 2010, Price = 4500 },
                new Listing { Make = fiat, Model = doblo, Year = 2011, Price = 5500 },

                new Listing { Make = renault, Model = megane, Year = 2005, Price = 750 },
                new Listing { Make = renault, Model = megane, Year = 2006, Price = 1750 },
                new Listing { Make = renault, Model = megane, Year = 2009, Price = 2750 },
                new Listing { Make = renault, Model = megane, Year = 2009, Price = 3750 },
                new Listing { Make = renault, Model = megane, Year = 2011, Price = 4750 },

                new Listing { Make = renault, Model = clio, Year = 2003, Price = 200 },
                new Listing { Make = renault, Model = clio, Year = 2004, Price = 1200 },
                new Listing { Make = renault, Model = clio, Year = 2007, Price = 2200 },
                new Listing { Make = renault, Model = clio, Year = 2005, Price = 3200 },
                new Listing { Make = renault, Model = clio, Year = 2006, Price = 4200 },
            };

            dumper.DumpJson("dump.json", listings);
        }
Пример #3
0
 public void InsertMake(Make make)
 {
     make.MakeId = _makes.Count() + 1;
     _makes.Add(make);
 }
        public void GetMakesByIdRuleTest(int id, string expectResult)
        {
            Make make = CarDearlershipRespoFacotory.GetRepository().GetMakesById(id);

            Assert.AreEqual(expectResult, make.MakeName);
        }
Пример #5
0
 public void edit(Make make)
 {
     context.Makes.Update(make);
 }
 public bool InsertMake(Make mk)
 {
     return(mkDa.InsertMake(mk));
 }
Пример #7
0
        protected override void Seed(EntityStore context)
        {
            const string imageUrlBase = "/Content/images{0}";

            //Makes
            const string ferrariName      = "Ferrari";
            const string lamborghiniName  = "Lamborghini";
            const string bentleyName      = "Bentley";
            const string bugattiName      = "Bugatti";
            const string koenigseggName   = "Koenigsegg";
            const string porscheName      = "Porsche";
            string       makeImageUrlBase = string.Format(imageUrlBase, "/Makes/{0}.png");
            Make         ferrari          = new Make {
                Name = ferrariName, Location = "Maranello, Italy", ImageUrl = string.Format(makeImageUrlBase, ferrariName)
            };
            Make lamborghini = new Make {
                Name = lamborghiniName, Location = "Sant'Agata Bolognese, Italy", ImageUrl = string.Format(makeImageUrlBase, lamborghiniName)
            };
            Make bentley = new Make {
                Name = bentleyName, Location = "Crewe, Cheshire, England", ImageUrl = string.Format(makeImageUrlBase, bentleyName)
            };
            Make bugatti = new Make {
                Name = bugattiName, Location = "Molsheim, France", ImageUrl = string.Format(makeImageUrlBase, bugattiName)
            };
            Make koenigsegg = new Make {
                Name = koenigseggName, Location = "Ängelholm, Sweden", ImageUrl = string.Format(makeImageUrlBase, koenigseggName)
            };
            Make porsche = new Make {
                Name = porscheName, Location = "Weissach, Germany", ImageUrl = string.Format(makeImageUrlBase, porscheName)
            };

            context.Makes.AddOrUpdate(m => m.Name, ferrari, lamborghini, bentley, bugatti, koenigsegg, porsche);

            //Models
            int   ferrariId        = context.Makes.First(x => x.Name == ferrariName).Id;
            int   lamboId          = context.Makes.First(x => x.Name == lamborghiniName).Id;
            int   bentleyId        = context.Makes.First(x => x.Name == bentleyName).Id;
            int   bugattiId        = context.Makes.First(x => x.Name == bugattiName).Id;
            Model ferrari458Spider = new Model {
                MakeId = ferrariId, Year = 2013, Name = "458 Spider", Description = "The Ferrari 458 Spider offers a whole new set of emotions and adds a genuine sense of sportiness and power to weekend trips à deux. A clever mix of sounds supplied by the car’s 570 horse power incorporates just the right notes, turning it into music to your ears: music that acts as a brilliant soundtrack not only to the pleasure of driving a Prancing Horse car but in-car chat.", EngineType = "V8 - 90° - Direct Injection - Dry Sump", BreakHorsepower = 570, ZeroToSixty = 3.1m, TopSpeed = 199, BasePrice = 257000
            };
            Model lamboAventador = new Model {
                MakeId = lamboId, Year = 2013, Name = "Aventador LP 700-4", Description = "The Aventador LP 700-4 represents a whole new level of performance, sets new benchmarks in the super sports car segment, and provides a glimpse into the future. It’s a car that’s already achieved legendary status.", EngineType = "V12, 60°, MPI", BreakHorsepower = 700, ZeroToSixty = 2.7m, TopSpeed = 217, BasePrice = 397500
            };
            Model bentleyContinental = new Model {
                MakeId = bentleyId, Year = 2013, Name = "Contintental GT", Description = "From the company’s earliest days, our cars set new standards in automotive design and engineering. They were icons of motoring. These cars took the Grand Touring rulebook and rewrote it. The beautiful R-Type Continental in the 1950s and the Continental GT at the start of the 21st century. A revolution in Grand Touring At the start of a new decade we unveiled our masterpiece, the Continental GT. A stunning coupé that blends classic Bentley DNA with contemporary design and modern technology. The perfect fusion of supercar performance and handcrafted luxury ensures the remarkable, the Continental GT creates a revolution of its own. Welcome to a new chapter in Bentley's automotive history.", EngineType = "5998cc V12", BreakHorsepower = 567, ZeroToSixty = 4.3m, TopSpeed = 198, BasePrice = 215000
            };
            Model bugattiVeryron = new Model {
                MakeId = bugattiId, Year = 2013, Name = "Veyron 16.4", Description = "Boasting a maximum speed of more than 400 km per hour, the Veyron is unmatched in the super sports category. It offers a total of 736 kW (1,001 HP), and its ample power reserves even at high speeds are the fabric of dreams for luxury-class limousines: for a constant speed of 250 km/h, the Veyron only needs 270-280 HP. This means that the seven-gear clutch transmission works with a torque of up to 1,250 Newton meters. The Electronic Stability Program ensures the necessary flexibility and maneuverability at any speed. The Veyron reaches velocities that would literally lift the car off the ground – if it weren’t for its ingenious aerodynamics, which keeps it firmly on the road even at full speed. Adjusting the back spoiler, reducing ground clearance, opening and closing the lids – it all adds to the perfect balance between propulsion and downforce. Such a super sports car may not seem to be brought to a halt easily, but the Veyron’s ceramic brakes slow it down faster than it can accelerate. While it takes this exceptional car only 2.5 seconds to go from 0 to 100 km/h, it needs even less time – a mere 2.3 seconds – to come to a standstill from 100 (reference point). To reduce the risk of injuries in accidents, Bugatti had a Formula 1 safety concept adapted for the Veyron. All these technical details combine to make the Veyron a truly exceptional super sports car.", EngineType = "8.0 Liter W16", BreakHorsepower = 1001, ZeroToSixty = 2.5m, TopSpeed = 253, BasePrice = 1914000
            };

            context.Models.AddOrUpdate(m => m.Name, ferrari458Spider, lamboAventador, bentleyContinental, bugattiVeryron);

            //Model Images
            string spiderImageBase    = string.Format(imageUrlBase, "/Models/Ferrari458Spider/{0}.png");
            string aventadorImageBase = string.Format(imageUrlBase, "/Models/LamborghiniAventadorLP700-4/{0}.png");
            int    spiderId           = context.Models.First(x => x.Name == "458 Spider").Id;
            int    aventadorId        = context.Models.First(x => x.Name == "Aventador LP 700-4").Id;

            context.ModelImages.AddOrUpdate(x => new { x.ModelId, x.Order }, new Models.ModelImage {
                ModelId = spiderId, ShortDescription = "Front", LongDescription = "Front", Order = 1, HighResolutionUrl = string.Format(spiderImageBase, "Front_HighRez"), LowResolutionUrl = string.Format(spiderImageBase, "Front_LowRez")
            }, new Models.ModelImage {
                ModelId = spiderId, ShortDescription = "Rear", LongDescription = "Rear", Order = 2, HighResolutionUrl = string.Format(spiderImageBase, "Rear_HighRez"), LowResolutionUrl = string.Format(spiderImageBase, "Rear_LowRez")
            }, new Models.ModelImage {
                ModelId = spiderId, ShortDescription = "Side", LongDescription = "Side", Order = 3, HighResolutionUrl = string.Format(spiderImageBase, "Side_HighRez"), LowResolutionUrl = string.Format(spiderImageBase, "Side_LowRez")
            }, new Models.ModelImage {
                ModelId = spiderId, ShortDescription = "Top", LongDescription = "Top", Order = 4, HighResolutionUrl = string.Format(spiderImageBase, "Top_HighRez"), LowResolutionUrl = string.Format(spiderImageBase, "Top_LowRez")
            }, new Models.ModelImage {
                ModelId = aventadorId, ShortDescription = "Front", LongDescription = "Front", Order = 1, HighResolutionUrl = string.Format(aventadorImageBase, "Front_HighRez"), LowResolutionUrl = string.Format(spiderImageBase, "Front_LowRez")
            }, new Models.ModelImage {
                ModelId = aventadorId, ShortDescription = "Rear", LongDescription = "Rear", Order = 2, HighResolutionUrl = string.Format(aventadorImageBase, "Rear_HighRez"), LowResolutionUrl = string.Format(spiderImageBase, "Rear_LowRez")
            }, new Models.ModelImage {
                ModelId = aventadorId, ShortDescription = "Side", LongDescription = "Side", Order = 3, HighResolutionUrl = string.Format(aventadorImageBase, "Side_HighRez"), LowResolutionUrl = string.Format(spiderImageBase, "Side_LowRez")
            });

            //Order
            const string username = "******";

            context.Orders.AddOrUpdate(x => new { x.Username, x.MakeId, x.ModelId }, new Order {
                Username = username, MakeId = ferrariId, ModelId = spiderId, Date = DateTime.Now.AddDays(-7), TotalCharge = 280465
            });
        }
Пример #8
0
 public Bus(Make make) : base(make)
 {
 }
Пример #9
0
        public object AddMake(Make make)
        {
            db.Insert(make);

            return(new { code = 200, result = new { mode = make.Name } });
        }
Пример #10
0
        public static void Initialize(VegaContext context)
        {
            context.Database.EnsureCreated();

            // Look for any models.
            if (context.Makes.Any())
            {
                return;   // DB has been seeded
            }

            var makes = new Make[]
            {
                new Make {
                    ID = 1, Name = "Volks"
                },
                new Make {
                    ID = 2, Name = "Ford"
                },
                new Make {
                    ID = 3, Name = "Subaru"
                }
            };

            foreach (Make m in makes)
            {
                context.Makes.Add(m);
            }
            context.SaveChanges();

            if (context.Models.Any())
            {
                return;
            }

            var models = new Model[]
            {
                new Model {
                    MakeID = 1, Name = "Schiroco"
                },
                new Model {
                    MakeID = 1, Name = "Bug"
                },
                new Model {
                    MakeID = 2, Name = "Mustang"
                },
                new Model {
                    MakeID = 2, Name = "Fairlane"
                },
                new Model {
                    MakeID = 2, Name = "Pinto"
                },
                new Model {
                    MakeID = 3, Name = "Imprezo"
                },
                new Model {
                    MakeID = 3, Name = "Forester"
                },
                new Model {
                    MakeID = 3, Name = "Outback"
                }
            };

            foreach (Model m in models)
            {
                context.Models.Add(m);
            }

            context.SaveChanges();

            if (context.Features.Any())
            {
                return;
            }

            var features = new Feature[]
            {
                new Feature {
                    Name = "Air Conditioning"
                },
                new Feature {
                    Name = "Heated Seats"
                },
                new Feature {
                    Name = "Fog Lights"
                },
                new Feature {
                    Name = "Jet Pack"
                },
                new Feature {
                    Name = "Rocket Launcher"
                }
            };

            foreach (Feature f in features)
            {
                context.Features.Add(f);
            }

            context.SaveChanges();
        }
Пример #11
0
        public ActionResult Edit(VehicleVM vehicle)
        {
            int.TryParse(vehicle.Mileage, out int carMileage);
            decimal carPrice = (decimal)vehicle.SalePrice;
            decimal carMSRP  = (decimal)vehicle.MSRP;

            if (carMileage >= 1000 && vehicle.CarType == "New")
            {
                vehicle.MakesDropDown  = new SelectList(Factory.MakeRepo().Get(), nameof(Make.MakeID), nameof(Make.MakeName));
                vehicle.ModelsDropDown = new SelectList(Factory.ModelRepo().Get(), nameof(Model.ModelID), nameof(Model.ModelName));

                ModelState.AddModelError("Add", "Car cannot be new if mileage is 1000 or more");

                return(View(vehicle));
            }

            if (carPrice > carMSRP)
            {
                vehicle.MakesDropDown  = new SelectList(Factory.MakeRepo().Get(), nameof(Make.MakeID), nameof(Make.MakeName));
                vehicle.ModelsDropDown = new SelectList(Factory.ModelRepo().Get(), nameof(Model.ModelID), nameof(Model.ModelName));

                ModelState.AddModelError("Add", "Sale Price CANNOT be greater than MSRP");
                return(View(vehicle));
            }

            if (ModelState.IsValid)
            {
                Model carModel = new Model();

                carModel = Factory.ModelRepo().GetByID(vehicle.ModelID);

                Make make = new Make();

                make = Factory.MakeRepo().GetById(vehicle.MakeID);

                Car car = new Car()
                {
                    CarID          = vehicle.CarID,
                    Make           = make,
                    Model          = carModel,
                    ModelID        = vehicle.ModelID,
                    CarType        = vehicle.CarType,
                    BodyStyle      = vehicle.BodyStyle,
                    CarYear        = vehicle.CarYear,
                    Trans          = vehicle.Trans,
                    Color          = vehicle.Color,
                    Interior       = vehicle.Interior,
                    Mileage        = vehicle.Mileage,
                    Vin            = vehicle.Vin,
                    MSRP           = vehicle.MSRP,
                    SalePrice      = vehicle.SalePrice,
                    CarDescription = vehicle.CarDescription,
                    IsFeatured     = vehicle.IsFeatured,
                };

                Factory.Create().Update(car);

                return(RedirectToAction("Vehicles"));
            }

            vehicle.MakesDropDown  = new SelectList(Factory.MakeRepo().Get(), nameof(Make.MakeID), nameof(Make.MakeName));
            vehicle.ModelsDropDown = new SelectList(Factory.ModelRepo().Get(), nameof(Model.ModelID), nameof(Model.ModelName));


            return(View(vehicle));
        }
Пример #12
0
        public ActionResult Add(VehicleVM vehicle)
        {
            int     carMileage = int.Parse(vehicle.Mileage);
            decimal carPrice   = (decimal)vehicle.SalePrice;
            decimal carMSRP    = (decimal)vehicle.MSRP;


            if (carMileage >= 1000 && vehicle.CarType == "New")
            {
                vehicle.MakesDropDown  = new SelectList(Factory.MakeRepo().Get(), nameof(Make.MakeID), nameof(Make.MakeName));
                vehicle.ModelsDropDown = new SelectList(Factory.ModelRepo().Get(), nameof(Model.ModelID), nameof(Model.ModelName));

                ModelState.AddModelError("Add", "Car cannot be new if mileage is 1000 or more");
                return(View(vehicle));
            }

            if (carPrice > carMSRP)
            {
                vehicle.MakesDropDown  = new SelectList(Factory.MakeRepo().Get(), nameof(Make.MakeID), nameof(Make.MakeName));
                vehicle.ModelsDropDown = new SelectList(Factory.ModelRepo().Get(), nameof(Model.ModelID), nameof(Model.ModelName));

                ModelState.AddModelError("Add", "Sale Price CANNOT be greater than MSRP");
                return(View(vehicle));
            }

            if (ModelState.IsValid)
            {
                Make make = Factory.MakeRepo().GetById(vehicle.MakeID);

                Model carModel = Factory.ModelRepo().GetByID(vehicle.ModelID);

                carModel.Make = make;

                int returnInt = 0;

                Car car = new Car()
                {
                    Model          = carModel,
                    Make           = carModel.Make,
                    ModelID        = vehicle.ModelID,
                    CarType        = vehicle.CarType,
                    BodyStyle      = vehicle.BodyStyle,
                    CarYear        = vehicle.CarYear,
                    Trans          = vehicle.Trans,
                    Color          = vehicle.Color,
                    Interior       = vehicle.Interior,
                    Mileage        = vehicle.Mileage,
                    Vin            = vehicle.Vin,
                    MSRP           = vehicle.MSRP,
                    SalePrice      = vehicle.SalePrice,
                    CarDescription = vehicle.CarDescription,
                };

                Factory.Create().Create(car);

                if (vehicle.CarPic != null && vehicle.CarPic.ContentLength > 0)
                {
                    string type = "." + vehicle.CarPic.ContentType.Substring(6);
                    vehicle.CarType = type;
                    if (type == ".png" || type == ".jpg" || type == ".jpeg")
                    {
                        returnInt       = car.CarID;
                        car.PicturePath = "/Images/inventory-" + returnInt + type;
                        string path = Path.Combine(Server.MapPath(car.PicturePath));
                        if (System.IO.File.Exists(path))
                        {
                            System.IO.File.Delete(path);
                        }

                        vehicle.CarPic.SaveAs(path);
                    }
                }

                return(RedirectToAction("Vehicles"));
            }

            vehicle.MakesDropDown  = new SelectList(Factory.MakeRepo().Get(), nameof(Make.MakeID), nameof(Make.MakeName));
            vehicle.ModelsDropDown = new SelectList(Factory.ModelRepo().Get(), nameof(Model.ModelID), nameof(Model.ModelName));


            return(View(vehicle));
        }
Пример #13
0
 public Vehicle(Make make, string model)
 {
     Make  = make;
     Model = model;
 }
Пример #14
0
 protected Vehicle(Make make)
 {
     _make = make;
 }
Пример #15
0
 public int CompareTo(Vehicle other)
 {
     return(Make.CompareTo(other.Make));
 }
Пример #16
0
 public void Add(Make make)
 {
     _context.Add(make);
 }
Пример #17
0
 public override int GetHashCode()
 {
     return(Make.GetHashCode() + Model.GetHashCode());
 }
Пример #18
0
 public void AddMake(Make make)
 {
     context.Makes.Add(make);
     context.SaveChanges();
 }
Пример #19
0
 public Make Save([FromBody] Make make)
 {
     return(makeRepository.Save(make));
 }
Пример #20
0
        public async Task <bool> EditAsync(
            int id,
            Make make,
            string model,
            decimal price,
            string imageUrl,
            int quantity,
            int frameSize,
            string wheelesMake,
            string forkMake,
            string tiresMake,
            string shiftersMake,
            string frontDerailleur,
            string rearDerailleur,
            string chain,
            string saddle,
            string handlebar,
            string brakes,
            string color,
            string brakeLevers,
            string batteryMake,
            int?batteryPower,
            string barTape,
            string rearShockMake,
            string kickstand,
            string userId)
        {
            var bike = this.db.Bikes.FirstOrDefault(b => b.Id == id && b.UserId == userId);

            if (bike == null)
            {
                return(false);
            }

            bike.Make            = make;
            bike.Model           = model;
            bike.Price           = price;
            bike.ImageUrl        = imageUrl;
            bike.Quantity        = quantity;
            bike.FrameSize       = frameSize;
            bike.WheelesMake     = wheelesMake;
            bike.ForkMake        = forkMake;
            bike.TiresMake       = tiresMake;
            bike.ShiftersMake    = shiftersMake;
            bike.FrontDerailleur = frontDerailleur;
            bike.RearDerailleur  = rearDerailleur;
            bike.Chain           = chain;
            bike.Saddle          = saddle;
            bike.Handlebar       = handlebar;
            bike.Brakes          = brakes;
            bike.Color           = color;
            bike.BrakeLevers     = brakeLevers;
            bike.BatteryMake     = batteryMake;
            bike.BatteryPower    = batteryPower;
            bike.BarTape         = barTape;
            bike.RearShockMake   = rearShockMake;
            bike.Kickstand       = kickstand;
            bike.UserId          = userId;

            await this.db.SaveChangesAsync();

            return(true);
        }
Пример #21
0
        // GET: Fillups/Create
        public IActionResult Create(int vehicleID, string ownerName, DateTime vehicleYear, Make vehicleMake, string vehicleModel)
        {
            var model = new AddFIllupVM
            {
                VehicleID    = vehicleID,
                OwnerName    = ownerName,
                VehicleYear  = vehicleYear,
                VehicleMake  = vehicleMake,
                VehicleModel = vehicleModel
            };

            return(View(model));
        }
Пример #22
0
        public async Task PostCreateShouldReturnRedirectWitValidModel()
        {
            const Make    DragMake            = Make.Drag;
            const string  BikeModel           = "Master Pro";
            const decimal BikePrice           = 890.67m;
            const string  BikeImageUrl        = "https://dragzone.bg/media/catalog/product/cache/1/image/500x500/9df78eab33525d08d6e5fb8d27136e95/_/3/_31466000117c_15074.jpg";
            const int     BikeFrameSize       = 550;
            const string  BikeWheelesMake     = "Kenda";
            const string  BikeForkMake        = "RockShock";
            const string  BikeTiresMake       = "Maxxis";
            const string  BikeShiftersMake    = "Dura Ace";
            const string  BikeFrontDerailleur = "Verosice";
            const string  BikeRearDerailleur  = "Verosice";
            const string  BikeChain           = "Kenda"
                                                const string BikeSaddle = "Selle Italia";
            const string BikeHandlebar = "SomeTest";
            const string BikeBrakes    = "Brembo";

            // Arrange
            Make    modelMake            = Make.Drag;
            string  modelModel           = null;
            decimal modelPrice           = default(decimal);
            string  modelImageUrl        = null;
            int     modelQuantity        = default(int);
            int     modelFrameSize       = default(int);
            string  modelWheelesMake     = null;
            string  modelForkMake        = null;
            string  modelTiresMake       = null;
            string  modelShiftersMake    = null;
            string  modelFrontDerailleur = null;
            string  modelRearDerailleur  = null;
            string  modelChain           = null;
            string  modelSaddle          = null;
            string  modelHandlebar       = null;
            string  modelBrakes          = null;
            string  modelColor           = null;
            string  modelBrakeLevers     = null;
            string  modelBatteryMake     = null;
            int?    modelBatteryPower    = null;
            string  modelBarTape         = null;
            string  modelRearShockMake   = null;
            string  modelKickstand       = null;
            string  modelUserId          = null;

            string successMessage = null;

            var userManager = UserManagerMock.New;
            var bikeService = new Mock <IBikeService>();

            bikeService
            .Setup(b => b.CreateAsync(
                       It.IsAny <Make>(),
                       It.IsAny <string>(),
                       It.IsAny <decimal>(),
                       It.IsAny <string>(),
                       It.IsAny <int>(),
                       It.IsAny <int>(),
                       It.IsAny <string>(),
                       It.IsAny <string>(),
                       It.IsAny <string>(),
                       It.IsAny <string>(),
                       It.IsAny <string>(),
                       It.IsAny <string>(),
                       It.IsAny <string>(),
                       It.IsAny <string>(),
                       It.IsAny <string>(),
                       It.IsAny <string>(),
                       It.IsAny <string>(),
                       It.IsAny <string>(),
                       It.IsAny <string>(),
                       It.IsAny <int>(),
                       It.IsAny <string>(),
                       It.IsAny <string>(),
                       It.IsAny <string>(),
                       It.IsAny <string>()))
            .Callback((Make make,
                       string model,
                       decimal price,
                       string imageUrl,
                       int quantity,
                       int frameSize,
                       string wheelesMake,
                       string forkMake,
                       string tiresMake,
                       string shiftersMake,
                       string frontDerailleur,
                       string rearDerailleur,
                       string chain,
                       string saddle,
                       string handlebar,
                       string brakes
                       ) =>
            {
                modelMake            = make;
                modelModel           = model;
                modelPrice           = price;
                modelImageUrl        = imageUrl;
                modelQuantity        = quantity;
                modelFrameSize       = frameSize;
                modelWheelesMake     = wheelesMake;
                modelForkMake        = forkMake;
                modelTiresMake       = tiresMake;
                modelShiftersMake    = shiftersMake;
                modelFrontDerailleur = frontDerailleur;
                modelRearDerailleur  = rearDerailleur;
                modelChain           = chain;
                modelSaddle          = saddle;
                modelHandlebar       = handlebar;
                modelBrakes          = brakes;
            })
            .Returns(Task.CompletedTask);

            var tempData = new Mock <ITempDataDictionary>();

            tempData.SetupSet(t => t[GlobalConstants.TempDataSuccessMessageKey] = It.IsAny <string>())
            .Callback((string key, object message) => successMessage            = message as string);

            var controller = new BikesController(bikeService.Object, userManager.Object);

            controller.TempData = tempData.Object;

            // Act
            var result = await controller.Create(new BikeFormModel
            {
                Make            = DragMake,
                Model           = BikeModel,
                Price           = BikePrice,
                ImageUrl        = BikeImageUrl,
                Quantity        = 1,
                FrameSize       = BikeFrameSize,
                WheelesMake     = BikeWheelesMake,
                ForkMake        = BikeForkMake,
                TiresMake       = BikeTiresMake,
                ShiftersMake    = BikeShiftersMake,
                FrontDerailleur = BikeFrontDerailleur,
                RearDerailleur  = BikeRearDerailleur,
                Chain           = BikeChain,
                Saddle          = BikeSaddle,
                Handlebar       = BikeHandlebar,
                Brakes          = BikeBrakes
            });

            // Assert
            modelMake.Should().Be(Make.Drag);
            modelModel.Should().Be(BikeModel);
            modelPrice.Should().Be(BikePrice);
            modelImageUrl.Should().Be(BikeImageUrl);
            modelQuantity.Should().Be(1);
            modelFrameSize.Should().Be(BikeFrameSize);
            modelWheelesMake.Should().Be(BikeWheelesMake);
            modelForkMake.Should().Be(BikeForkMake);
            modelTiresMake.Should().Be(BikeTiresMake);
            modelShiftersMake.Should().Be(BikeShiftersMake);
            modelFrontDerailleur.Should().Be(BikeFrontDerailleur);
            modelRearDerailleur.Should().Be(BikeRearDerailleur);
            modelChain.Should().Be(BikeChain);
            modelSaddle.Should().Be(BikeSaddle);
            modelHandlebar.Should().Be(BikeHandlebar);;
            modelBrakes.Should().Be(BikeBrakes);

            successMessage.Should().Be($"Bike {DragMake} {BikeModel} created successfully!");

            result.Should().BeOfType <RedirectToActionResult>();

            result.As <RedirectToActionResult>().ActionName.Should().Be("Index");
        }
Пример #23
0
        public async Task GetRelatedEntitiesCountShouldReturnCorrectValues()
        {
            var options = new DbContextOptionsBuilder <NeedForCarsDbContext>()
                          .UseInMemoryDatabase("RelatedEntitiesDb_generations")
                          .Options;

            var context = new NeedForCarsDbContext(options);

            var makesService       = new MakesService(context);
            var modelsService      = new ModelsService(context, makesService);
            var generationsService = new GenerationsService(context, modelsService);

            var make = new Make
            {
                Name        = "Make",
                Description = "Desc"
            };
            await context.Makes.AddAsync(make);

            var model = new Model
            {
                MakeId = make.Id,
                Name   = "Model1",
            };
            await context.Models.AddAsync(model);

            var generation = new Generation
            {
                ModelId = model.Id,
                Name    = "Model1"
            };
            await context.Generations.AddAsync(generation);

            var engine = new Engine
            {
                Name     = "engine",
                MaxHP    = 100,
                FuelType = Models.Enums.FuelType.Diesel,
                Creator  = "creator"
            };
            await context.Engines.AddAsync(engine);

            var car = new Car
            {
                GenerationId = generation.Id,
                EngineId     = engine.Id,
                Transmission = Models.Enums.Transmission.Automatic,
                DriveWheel   = Models.Enums.DriveWheel.AllWheelDrive,
                BeginningOfProductionYear  = 2000,
                BeginningOfProductionMonth = 1
            };
            await context.Cars.AddAsync(car);

            var user = new NeedForCarsUser
            {
                Email        = "*****@*****.**",
                UserName     = "******",
                PasswordHash = "HASHEDPASSWORD",
                FirstName    = "First",
                LastName     = "Last",
                PhoneNumber  = "1234567890"
            };
            await context.Users.AddAsync(user);

            var userCar = new UserCar
            {
                OwnerId             = user.Id,
                CarId               = car.Id,
                Color               = "color",
                ProductionDateYear  = 2000,
                ProductionDateMonth = 1,
                Mileage             = 0
            };
            await context.UserCars.AddAsync(userCar);

            await context.SaveChangesAsync();

            generationsService.GetRelatedEntitiesCount(generation, out int cars, out int userCars);

            Assert.True(cars == 1 && userCars == 1);
        }
Пример #24
0
 public virtual void PrintInfo()
 {
     Console.WriteLine(Make.PadRight(8, ' ') + "\t" + Model.PadRight(8, ' ') + "\t" + Year.ToString().PadRight(8, ' ') + "\t" + "$" + Price.ToString("N2"));
 }
Пример #25
0
 public Ad(Make m)
 {
     make = m;
 }
Пример #26
0
 public ICarAdFactory WithMake(Make make)
 {
     this.make      = make;
     this.isMakeSet = true;
     return(this);
 }
Пример #27
0
 public ProdPlace(Make m) : base(m)
 {
 }
Пример #28
0
        // GET: Category



        public ActionResult Index(Guid id)
        {
            if (CategoryDAL.Get(x => x.CategoryID == id) != null)
            {
                VMCategoryListing vmList = new VMCategoryListing();
                Session["id"] = id;

                ICollection <Category> subCategoryList = new HashSet <Category>();
                GetSubCategory(id, ref subCategoryList);

                vmList.CategoryList = subCategoryList;

                ICollection <VMCategoryProduct> list = new HashSet <VMCategoryProduct>();
                GetMainProductList(ref list, subCategoryList);


                vmList.ProductList = list;

                ICollection <Make> mList = new HashSet <Make>();
                foreach (var m in MakeDAL.GetList())
                {
                    foreach (var cat in subCategoryList)
                    {
                        foreach (var make in cat.Makes)
                        {
                            if (m == make)
                            {
                                mList.Add(m);
                            }
                        }
                    }
                }
                vmList.MakeList = mList;
                return(View(vmList));
            }
            else if (MakeDAL.Get(x => x.MakeID == id) != null)
            {
                Make make = new Make();
                make = MakeDAL.Get(x => x.MakeID == id);
                Guid catID = Guid.Parse("35391ff3-c30d-4a6a-b30b-14079eaaa455");

                VMCategoryListing vmList = new VMCategoryListing();
                Session["id"] = catID;

                ICollection <Category> subCategoryList = new HashSet <Category>();
                foreach (var cat in make.Categories)
                {
                    subCategoryList.Add(cat);
                }

                vmList.CategoryList = subCategoryList;

                ICollection <VMCategoryProduct> list = new HashSet <VMCategoryProduct>();
                #region makeProductsGet
                foreach (var m in make.Models)
                {
                    foreach (var p in m.Products)
                    {
                        VMCategoryProduct vmProduct = new VMCategoryProduct();
                        vmProduct.ProductID    = p.ProductID;
                        vmProduct.ModelID      = p.ModelID;
                        vmProduct.MakeID       = p.ProductModel.MakeID;
                        vmProduct.ProductName  = p.ProductName;
                        vmProduct.UnitPrice    = p.UnitPrice;
                        vmProduct.UnitsInStock = p.UnitsInStock;
                        vmProduct.ViewCount    = p.ViewCount;
                        vmProduct.Description  = p.Description;
                        vmProduct.IsActive     = p.IsActive;
                        vmProduct.PicturePath  = p.ProductPictures.First().PicturePath;
                        vmProduct.ModelName    = p.ProductModel.ModelName;

                        if (p.Campaigns.Count != 0)
                        {
                            vmProduct.hasCampaign = true;

                            string  discount = "";
                            decimal price    = p.UnitPrice;
                            int     count    = p.Campaigns.Count;
                            foreach (var campaign in p.Campaigns.Where(x => x.IsActive == true))
                            {
                                if (campaign.StartedDate < DateTime.Now && campaign.EndingDate > DateTime.Now)
                                {
                                    discount += "%" + (Convert.ToInt32(campaign.Discount * 100)).ToString();
                                    price    *= (1 - campaign.Discount);

                                    if (count > 1)
                                    {
                                        discount += "+"; count--;
                                    }
                                }
                            }
                            vmProduct.TotalPrice    = price;
                            vmProduct.TotalDiscount = discount;
                            vmProduct.OldPrice      = p.UnitPrice;
                        }
                        else
                        {
                            vmProduct.TotalPrice    = p.UnitPrice;
                            vmProduct.TotalDiscount = "";
                            vmProduct.hasCampaign   = false;
                        }

                        list.Add(vmProduct);
                    }
                }
                #endregion

                vmList.ProductList = list;
                ICollection <Make> mList = new HashSet <Make>();
                mList.Add(make);
                vmList.MakeList = mList;
                return(View(vmList));
            }
            else
            {
                return(Json(false));
            }
        }
Пример #29
0
        private void DispatchCarFromJSON(string json)
        {
            dynamic carDeserializedResponse = JsonConvert.DeserializeObject(json);

            int returnCode = -1;

            if (!int.TryParse(carDeserializedResponse.returnCode.ToString(), out returnCode) || returnCode == -1)
            {
                return;
            }

            dynamic lotDetails = carDeserializedResponse.data.lotDetails;

            string lot = lotDetails.ln.ToString();

            if (this.ServicesDispatcher.EntityExists <Car>(lot))
            {
                return;
            }

            string dirtyModel = lotDetails.lm ?? string.Empty;

            string[] splitModel = dirtyModel.Split(' ');
            string   modelValue = (splitModel.Length > 0) ? splitModel[0] : string.Empty;
            string   version    = (splitModel.Length > 1) ? string.Join(" ", splitModel.Skip(1)) : string.Empty;

            int    year          = lotDetails.lcy;
            string title         = lotDetails.ld ?? string.Empty;
            string vin           = lotDetails.fv ?? string.Empty;
            int    estimateValue = lotDetails.la;
            int    odometer      = lotDetails.orr;

            int engine = 0;

            int.TryParse(Regex.Match((lotDetails.egn ?? string.Empty).ToString(), @"\d+").Value, out engine);

            string primaryDamage   = lotDetails.dd ?? string.Empty;
            string secondaryDamage = lotDetails.sdd ?? string.Empty;
            string bodyStyle       = lotDetails.bstl ?? string.Empty;
            string drive           = lotDetails.drv ?? string.Empty;

            double auctionTimestamp = 0;

            double.TryParse((lotDetails.ad ?? string.Empty).ToString(), out auctionTimestamp);
            DateTime auctionOn = UnixTimeStampToDateTime(auctionTimestamp);

            Make make = this.ServicesDispatcher.GetEntity <Make>((lotDetails.mkn ?? string.Empty).ToString());

            Model model = this.modelsService.Get(x => x.Value == modelValue && x.MakeId == make.Id);

            if (model == null)
            {
                model = new Model
                {
                    Value  = modelValue,
                    MakeId = make.Id
                };
                this.modelsService.Add(model);
            }

            Category     category     = this.ServicesDispatcher.GetEntity <Category>((lotDetails.td ?? string.Empty).ToString());
            Location     location     = this.ServicesDispatcher.GetEntity <Location>((lotDetails.yn ?? string.Empty).ToString());
            Currency     currency     = this.ServicesDispatcher.GetEntity <Currency>((lotDetails.cuc ?? string.Empty).ToString());
            Transmission transmission = this.ServicesDispatcher.GetEntity <Transmission>((lotDetails.tsmn ?? string.Empty).ToString());
            Fuel         fuel         = this.ServicesDispatcher.GetEntity <Fuel>((lotDetails.ftd ?? string.Empty).ToString());
            Color        color        = this.ServicesDispatcher.GetEntity <Color>((lotDetails.clr ?? string.Empty).ToString());

            Car car = new Car
            {
                MakeId          = make.Id,
                ModelId         = model.Id,
                CategoryId      = category.Id,
                LocationId      = location.Id,
                CurrencyId      = currency.Id,
                TransmissionId  = transmission.Id,
                FuelId          = fuel.Id,
                ColorId         = color.Id,
                Lot             = lot,
                Version         = version,
                Year            = year,
                Title           = title,
                VIN             = vin,
                EstimateValue   = estimateValue,
                Odometer        = odometer,
                Engine          = engine,
                PrimaryDamage   = primaryDamage,
                SecondaryDamage = secondaryDamage,
                BodyStyle       = bodyStyle,
                Drive           = drive,
                AuctionOn       = auctionOn
            };

            this.ServicesDispatcher.AddEntity(car, lot);

            // fetch images
            string carJSON = JsonConvert.SerializeObject(lotDetails);

            this.FetchLotImagesFromWeb(lot, carJSON, car.Id);
        }
Пример #30
0
 public Video(Make m) : base(m)
 {
 }
 protected async override Task OnParametersSetAsync()
 {
     make = await _client.Get(Endpoints.MakesEndpoint, id);
 }
Пример #32
0
 public void Add(Make make)
 {
     makes.Add(make);
 }
Пример #33
0
        public string AddMake(string make, int yearID)
        {
            string response = "";
            make = Uri.UnescapeDataString(make);
            CurtDevDataContext db = new CurtDevDataContext();
            YearMake ym = new YearMake();

            if (make.Length > 0 && yearID > 0) {
                // Make sure this make / year combo doesn't exist
                int mCount = (from m in db.Makes
                              join y in db.YearMakes on m.makeID equals ym.makeID
                              where m.make1.Equals(make) && y.yearID.Equals(yearID)
                              select m).Count<Make>();
                if(mCount == 0) {
                    Make new_make = new Make();
                    try {
                        new_make = db.Makes.Where(x => x.make1.Equals(make)).First<Make>();
                    } catch {
                        new_make = new Make {
                            make1 = make.Trim()
                        };
                        db.Makes.InsertOnSubmit(new_make);
                        db.SubmitChanges();
                    }

                    try {
                        ym = new YearMake {
                            makeID = new_make.makeID,
                            yearID = yearID
                        };
                        db.YearMakes.InsertOnSubmit(ym);
                        db.SubmitChanges();
                        JavaScriptSerializer ser = new JavaScriptSerializer();
                        response = ser.Serialize(new_make);
                    } catch (Exception e) {
                        response = "[{\"error\":\""+e.Message+"\"}]";
                    }
                } else {
                    response = "[{\"error\":\"This make already exists for this model year.\"}]";
                }
            }
            return response;
        }