public ViewResult Checkout(lot new_lot) { LotRepository lotRep = new LotRepository(); lotRep.Save(new_lot); return View("Thanks"); }
private void LotUpdated(object sender, EventArgs e) { LotRepository lotRepository = new LotRepository(new MyDbContext()); UserRepository userRepository = new UserRepository(new MyDbContext()); user = userRepository.Get(user.Name); lot = lotRepository.Get(lot.Id); LoadLot(); }
/// <summary> /// Initializes the instance of the unit of work with context /// </summary> /// <param name="context"></param> public UnitOfWork(ApplicationDbContext context) { _context = context; ApplicationUserManager = new ApplicationUserManager(new UserStore <ApplicationUser>(context)); ApplicationRoleManager = new ApplicationRoleManager(new RoleStore <ApplicationRole>(context)); CarRepository = new CarRepository(context); LotRepository = new LotRepository(context); BetRepository = new BetRepository(context); Logger = new Logger(context); }
public ActionResult GetAdmin() { LotRepository lotRep = new LotRepository(); Expression<Func<lot, bool>> filter = x => x.statusID == (int)Status.view; List<lot> lots = lotRep.Get(filter).ToList(); DropDownInit(); return View(lots); }
public Auction(MyDbContext db, Acccount acccount, User user) { this.db = db; lotRepository = new LotRepository(db); userRepository = new UserRepository(db); InitializeComponent(); this.user = user; this.acccount = acccount; Update_LotsFromData(); Update_AvailableLots(); Update_PlannedLots(); }
public async Task LotRepository_GetByIdAsync_ReturnsProperLot() { var lot = GetTestLots().First(); var mockDbSet = UnitTestHelper.GetMockDbSet <Lot>(GetTestLots().AsQueryable()); var mockContext = GetMockContext(mockDbSet); var lotRepo = new LotRepository(mockContext.Object); var result = await lotRepo.GetByIdAsync(lot.Id); Assert.AreEqual(lot.Id, result.Id); Assert.AreEqual(lot.TurnkeyPrice, result.TurnkeyPrice); Assert.AreEqual(lot.Car?.Id, result.Car?.Id); }
public async Task LotRepository_DeleteByIdAsync_DeletesLot() { var mockDbSet = UnitTestHelper.GetMockDbSet <Lot>(GetTestLots()); var mockContext = GetMockContext(mockDbSet); var lotRepo = new LotRepository(mockContext.Object); var id = 1; await lotRepo.DeleteByIdAsync(id); mockDbSet.Verify( m => m.Remove(It.Is <Lot>( l => l.Id == id)), Times.Once); }
public Acccount(User user) { lotRepository = new LotRepository(db); userRepository = new UserRepository(db); InitializeComponent(); this.user = user; this.UserName_label.Text = user.Name; Update_LotsFromData(); Update_MyLots(); Update_BoughtLots(); Update_Balance(); }
public ActionResult GetAdmin(lot change_lot) { LotRepository lotRep = new LotRepository(); Expression<Func<lot, bool>> filter = x => x.lotID == change_lot.lotID; List<lot> c_lot = lotRep.Get(filter).ToList(); c_lot[0].statusID = change_lot.statusID; lotRep.Save(c_lot[0]); filter = x => x.statusID == (int)Status.view; List<lot> lots = lotRep.Get(filter).ToList(); DropDownInit(); return View(lots); }
public BidForm(MyDbContext db, Lot lot, User user, Auction auction) { this.db = db; lotRepository = new LotRepository(db); userRepository = new UserRepository(db); InitializeComponent(); this.lot = lot; this.user = user; this.auction = auction; timer1.Start(); timeLeft = maxTimeLeftInMinutes * 60; panel1.Visible = false; LoadLot(); lotRepository.LotUpdated += this.LotUpdated; }
public void LotRepository_FindAll_ReturnsAllLots() { var lots = GetTestLots().ToList(); var mockDbSet = UnitTestHelper.GetMockDbSet <Lot>(lots.AsQueryable()); var mockContext = GetMockContext(mockDbSet); var lotRepo = new LotRepository(mockContext.Object); var result = lotRepo.FindAll().ToList(); Assert.AreEqual(lots.Count, result.Count); for (int i = 0; i < result.Count; i++) { Assert.AreEqual(lots[i].Id, result[i].Id); Assert.AreEqual(lots[i].TurnkeyPrice, result[i].TurnkeyPrice); Assert.AreEqual(lots[i].Car?.Id, result[i].Car?.Id); } }
public ViewResult Index(int? current_category, int? current_city, string part_name) { LotRepository lotRep = new LotRepository(); Expression<Func<lot, bool>> filter = x => (x.cityID == current_city && current_city != null || current_city == null) && (x.categoryID == current_category && current_category != null || current_category == null) && (x.name.IndexOf(part_name.Trim()) != -1 && part_name.Trim() != "" || part_name.Trim() == "") && x.statusID == (int)Status.approve; List<lot> lots = lotRep.Get(filter).ToList(); DropDownInit(); LotsListViewModel model = new LotsListViewModel { lots = lots }; return View(model); }
public void LotRepository_Delete_DeletesLot() { var mockDbSet = UnitTestHelper.GetMockDbSet <Lot>(GetTestLots()); var mockContext = GetMockContext(mockDbSet); var lotRepo = new LotRepository(mockContext.Object); var lot = new Lot { Id = 1, TurnkeyPrice = 5000, CarId = 1 }; lotRepo.Delete(lot); mockDbSet.Verify( m => m.Remove(It.Is <Lot>( l => l.Id == lot.Id && l.TurnkeyPrice == lot.TurnkeyPrice && l.CarId == lot.CarId)), Times.Once); }
public ViewResult Index() { try { LotRepository lotRep = new LotRepository(); Expression<Func<lot, bool>> filter = x => x.statusID == (int)Status.approve; List<lot> lots = lotRep.Get(filter).ToList(); DropDownInit(); LotsListViewModel model = new LotsListViewModel { lots = lots }; return View(model); } catch (Exception error) { return View(); } }
protected override ValidationResult IsValid(object value, ValidationContext validationContext) { int id = ((LotEditModel)validationContext.ObjectInstance).Id; double oldPrice = new LotRepository().GetPrice(id); return (double)value > oldPrice ? null : new ValidationResult("Your rate should be > current rate"); }