public override void Process(TagHelperContext context, TagHelperOutput output) { output.TagName = "a"; Type type = Obj.GetType(); if (type == typeof(CarLot)) { CarLot lot = (CarLot)Obj; output.Attributes.SetAttribute("href", "/Lot/" + lot.Id); output.Content.SetContent(lot.Name); } else if (type == typeof(User)) { User user = (User)Obj; output.Attributes.SetAttribute("href", "/Account/Profile/" + user.Id); output.Content.SetContent(user.UserName); } }
public void InventoryShouldUseCachedVehicles() { // arrange MemoryCache memoryCache = new MemoryCache(new MemoryCacheOptions()); memoryCache.Set("inventory", new Inventory(new List <IVehicle> { new Vehicle(1, 1982, "Ford", "550 Bronco", 12425.95m) }), DateTimeOffset.Now.AddMinutes(1)); ICarLot carLot = new CarLot(memoryCache); carLot.Inventory(); // act // assert memoryCache.Get <IInventory>("inventory").VehicleDescriptions().Should().HaveCount(1); }
public IActionResult Detail(int?id) { if (id != null) { CarLot lot = carLotsRepository.GetDetailLot(id); if (lot != null) { LotDetailtViewModel lot2 = new LotDetailtViewModel { Lot = lot, BetPrice = lot.Price + 50, BetId = (int)id }; return(View(lot2)); } logger.LogError("Doesn't exist lot. Controller:Lots. Action:Details"); } logger.LogError("Doesn't exist id. Controller:Lots. Action:Details"); return(RedirectPermanent("~/Error/Index?statusCode=404")); }
static void Main(string[] args) { CarLot UsedLot = new CarLot("Used Auto"); Vehicle v1 = new Truck("CPP332D", "Ford", "F150", 60000, 6); Vehicle v2 = new Car("BCC244L", "Audi", "A8", "Sedan", 75000, 4); UsedLot.AddCars(v1); UsedLot.AddCars(v2); UsedLot.PrintInventory(); CarLot NewLot = new CarLot("New Auto"); Vehicle v3 = new Truck("YLF77D", "Cheverolet", "Colorado", 32000, 4); Vehicle v4 = new Car("PHF49O", "Nissan", "Rougue", "Crossover", 55000, 4); NewLot.AddCars(v3); NewLot.AddCars(v4); NewLot.PrintInventory(); Console.Read(); }
private async void saveCarPark() { try { btnSaveNewCarPark.IsEnabled = false; string strfacilityDetails = isolatedLocalStorage.Read(IsolatedFiles.facilityDetails); var deserializedFacility = JsonConvert.DeserializeObject <Facility>(strfacilityDetails); string strAuth = isolatedLocalStorage.Read(IsolatedFiles.authFile); var deserializedAuth = JsonConvert.DeserializeObject <Auth>(strAuth); CarLot carLot = new CarLot(); carLot.name = txtNameCarPark.Text.ToUpper(); carLot.facilityId = deserializedFacility.Id; string strCarParkItem = await httpClientServices.CreateAsync(EndPoints.carLots, carLot, deserializedAuth.AccessToken); var deserializedCarParkItem = JsonConvert.DeserializeObject <CarLot>(strCarParkItem); GetCarLot(); } catch (Exception ex) { } }
public DetailController() { _carLot = new CarLot() { Dealer = new Dealer() { Name = "Code Louisville Cars" } }; for (int carNumber = 0; carNumber < 100; carNumber++) { Car car = new Car() { Make = $"Make_{carNumber}", Model = $"Model_{carNumber}", Year = 2000 + carNumber }; _carLot.Cars.Add(car); } }
public async void deleteCarLot() { try { btnSaveNewCarParkDelete.IsEnabled = false; string strfacilityDetails = isolatedLocalStorage.Read(IsolatedFiles.facilityDetails); var deserializedFacility = JsonConvert.DeserializeObject <Facility>(strfacilityDetails); string strAuth = isolatedLocalStorage.Read(IsolatedFiles.authFile); var deserializedAuth = JsonConvert.DeserializeObject <Auth>(strAuth); string _strPost = await httpClientServices.DeleteAsync(EndPoints.carLots, selectedCarLot.id, deserializedAuth.AccessToken); var deserializedcarParkItem = JsonConvert.DeserializeObject <CarLot>(_strPost); selectedCarLot = null; btnSaveNewCarPark.Content = "Add"; GetCarPark(); } catch (Exception ex) { selectedCarLot = null; btnSaveNewCarPark.Content = "Add"; btnSaveNewCarParkDelete.IsEnabled = true; } }
public async Task <IActionResult> DeleteUser(string id) { User user = await _userManager.FindByIdAsync(id); if (user != null) { var lots = carRep.GetUserLots(user); List <Bet> userBets = db.Bets.Include(b => b.CarLot).Include(b => b.CarLot.Bets).Where(b => b.User.Id == id || b.CarLot.User.Id == id).ToList(); db.Bets.RemoveRange(db.Bets.Where(b => b.User.Id == id || b.CarLot.User.Id == id)); db.SaveChanges(); foreach (Bet bet in userBets) { CarLot stavkiOnCarLotUsera = bet.CarLot; if (stavkiOnCarLotUsera.Bets.Count != 0) { bet.CarLot.Price = stavkiOnCarLotUsera.Bets.Last().NewPrice; } else { bet.CarLot.Price = bet.CarLot.StartPrice; } } foreach (CarLot lot in lots) { string path = "wwwroot/images/" + lot.Id + ".jpg"; System.IO.File.Delete(path); } db.CarLots.RemoveRange(db.CarLots.Where(l => l.User.Id == id)); db.Users.Remove(user); await db.SaveChangesAsync(); } return(RedirectToAction("Index", "Users")); }
public void UpdateLot(CarLot lot) { carLotRepository.Update(lot); }
public void DeleteLot(CarLot lot) { carLotRepository.Delete(lot); }
public void AddLotDB(CarLot lot) { carLotRepository.Insert(lot); }
public string Invoke(CarLot lot, IViewLocalizer localizer) { TimeSpan left = lot.Ending - DateTime.UtcNow; return($"{left.Days} {localizer["D"].Value}. : {left.Hours} {localizer["H"].Value}. : {left.Minutes} {localizer["M"].Value}."); }
public PartialViewResult CommentsList(int id) { CarLot lot = carLotsRepository.GetDetailLot(id); return(PartialView(lot.Comments)); }
static void Main(string[] args) { bool keepBuying = true; Console.WriteLine("Welcome to the Grant Chirpus' Used Car Emporium!"); Console.WriteLine(); CarLot.AddCar(new Car("Nikolai", "Model S", 2017, 54999.90M)); CarLot.AddCar(new Car("Fourd", "Escapade", 2017, 31999.90M)); CarLot.AddCar(new Car("Chewie", "Vette", 2017, 44989.95M)); CarLot.AddCar(new UsedCar("Hyonda", "Prior", 2015, 14785.50M, 35987.6)); CarLot.AddCar(new UsedCar("GC", "\tChirpus", 2013, 8500.00M, 12345.0)); CarLot.AddCar(new UsedCar("GC", "\tWitherell", 2016, 14450.00M, 3500.3)); CarLot.PrintCar(); while (keepBuying) { Console.Write("Which car would you like?"); int input = int.Parse(Console.ReadLine()); if (input == CarLot.Inventory.Count + 2) //quit { Console.WriteLine("Good Bye!"); break; } else if (input > CarLot.Inventory.Count - 1) //add a car { Console.Write("Is the car new or used? (u/n):"); string userNew = Console.ReadLine().ToUpper(); if (userNew == "U") { Console.Write("Enter the Make:"); string Umake = Console.ReadLine(); Console.Write("Enter the Model:"); string Umodel = Console.ReadLine(); Console.Write("Enter the Year:"); int Uyear = int.Parse(Console.ReadLine()); Console.Write("Enter the Price:"); Decimal Uprice = Decimal.Parse(Console.ReadLine()); Console.Write("Enter the Mileage:"); int Umileage = int.Parse(Console.ReadLine()); CarLot.AddCar(new UsedCar(Umake, Umodel, Uyear, Uprice, Umileage)); CarLot.PrintCar(); } else if (userNew == "N") { Console.Write("Enter the Make:"); string make = Console.ReadLine(); Console.Write("Enter the Model:"); string model = Console.ReadLine(); Console.Write("Enter the Year:"); int year = int.Parse(Console.ReadLine()); Console.Write("Enter the Price:"); Decimal price = Decimal.Parse(Console.ReadLine()); CarLot.AddCar(new Car(make, model, year, price)); CarLot.PrintCar(); } else if (userNew != "U" || userNew != "N") { Console.WriteLine("Not a valid Choice"); continue; } } else if (input <= CarLot.Inventory.Capacity - 1) //This checks for inventory size -1 { Console.WriteLine(CarLot.Inventory[input - 1]); Console.Write("Would you like to buy this car? (y/n):"); string choice = Console.ReadLine().ToUpper(); if (choice == "Y") { CarLot.RemoveCar(CarLot.Inventory[input - 1]); Console.WriteLine("Excellent! Our finance department will be in touch shortly.!"); Console.WriteLine(); CarLot.PrintCar(); } else if (choice != "N") { Console.WriteLine("That is not a Valid Choice."); continue; } else if (choice == "N") { Console.WriteLine("Have a Great Day! Think about buying another car in the futrue."); keepBuying = false; } } } }