Пример #1
0
        public ViewResult Checkout(lot new_lot)
        {
            LotRepository lotRep = new LotRepository();
            lotRep.Save(new_lot);

            return View("Thanks");
        }
Пример #2
0
        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();
        }
Пример #3
0
 /// <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);
 }
Пример #4
0
        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);
        }
Пример #5
0
        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();
        }
Пример #6
0
        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);
        }
Пример #7
0
        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);
        }
Пример #8
0
        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();
        }
Пример #9
0
        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);
        }
Пример #10
0
        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;
        }
Пример #11
0
        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);
            }
        }
Пример #12
0
        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);
        }
Пример #13
0
        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);
        }
Пример #14
0
        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");
 }