예제 #1
0
        public void CreateLot_AcceptIdOfNotExistingItem_ThrowException()
        {
            //assign
            var mock = new Mock <IUnitOfWork>();

            mock.Setup(x => x.Products.Create(new Product {
                Id = 1
            }));
            var sud = new LotService(mock.Object);

            //act

            //assert
            Assert.Throws(typeof(NotFoundException), () => sud.CreateLot(2));
        }
예제 #2
0
        public void CreateLot_AcceptIdOfNotConfirmedItem_ThrowException()
        {
            //assign
            var mock = new Mock <IUnitOfWork>();

            mock.Setup(x => x.Products.Get(1)).Returns(new Product {
                Id = 1, IsConfirmed = false
            });
            var sud = new LotService(mock.Object);
            //act
            var message = Assert.Catch(typeof(InvalidOperationException), () => sud.CreateLot(1)).Message;

            //assert
            Assert.AreEqual("Not confirmed", message);
        }
예제 #3
0
        public ActionResult NewLot(LotViewModel lotFromView)
        {
            LotDTO     lotDTO = new LotDTO();
            LotService ls     = new LotService();

            lotDTO.Name         = lotFromView.Name;
            lotDTO.Description  = lotFromView.Description;
            lotDTO.InitialPrice = lotFromView.InitialPrice;
            lotDTO.LotTime      = lotFromView.LotTime;

            int userId = Convert.ToInt32(Request.Cookies["UserId"].Value);

            BLLMethodResult result = ls.CreateLot(lotDTO, userId);

            return(RedirectToAction("Message", "Home", new { str = result.Message }));
        }
예제 #4
0
        private void SaveLot()
        {
            SelectedLot           = LotDetailsVM.Lot;
            SelectedLot.auctionId = auction.Id;

            // Check for filled fields
            if (string.IsNullOrEmpty(SelectedLot.Number) || string.IsNullOrEmpty(SelectedLot.Name) || SelectedLot.Quantity == 0 || SelectedLot.Price == 0)
            {
                MessagesService.Show("Сохранение лота", "Не все поля заполненны");
                return;
            }

            if (SelectedLot.Id == 0)
            {
                int newLotId = LotService.CreateLot(SelectedLot);
            }
            else
            {
                LotService.UpdateLot(SelectedLot);
            }

            Init();
        }