private AdditiveLot LoadAttributes(AdditiveLot newLot, LotDTO oldLot)
        {
            newLot.Lot.Attributes = new List <LotAttribute>();

            var attributeData = new CreateChileLotHelper.AttributeCommonData(oldLot, this);

            foreach (var attributeName in StaticAttributeNames.AttributeNames)
            {
                var value = oldLot.AttributeGet(attributeName)();
                if (value != null)
                {
                    newLot.Lot.Attributes.Add(new LotAttribute
                    {
                        LotDateCreated     = newLot.LotDateCreated,
                        LotDateSequence    = newLot.LotDateSequence,
                        LotTypeId          = newLot.LotTypeId,
                        AttributeShortName = attributeName.ShortName,

                        AttributeValue = (double)value,
                        AttributeDate  = attributeData.DeterminedTestDate,

                        EmployeeId = attributeData.TesterId,
                        TimeStamp  = attributeData.EntryDate.Value,
                        Computed   = attributeData.NullTestDate
                    });
                }
            }

            return(newLot);
        }
Esempio n. 2
0
        /// <summary>
        /// Method for updating lot.
        /// </summary>
        /// <param name="lot">The lot DTO.</param>
        public void UpdateLot(LotDTO lot)
        {
            var mapped = _mapper.Map <Lot>(lot);

            _uow.Lots.Update(mapped);
            _uow.Save();
        }
Esempio n. 3
0
        public void ShuldReturnTrueIfGetLotsWork()
        {
            //Arrange
            Lot one = new Lot {
                Name = "a", Id = 1
            };
            LotDTO two = new LotDTO {
                Name = "a", Id = 1
            };

            Mock <IRepository <Lot> > repositoryMock = new Mock <IRepository <Lot> >();

            repositoryMock.Setup(a => a.GetAll()).Returns(new List <Lot>()
            {
                one
            });

            var uowMock = new Mock <IUnitOfWork>();

            uowMock.Setup(uow => uow.Lots).Returns(repositoryMock.Object);

            var lotService = new LotService(uowMock.Object);

            List <LotDTO> expected = new List <LotDTO>();

            expected.Add(two);



            //Act
            List <LotDTO> actual = (List <LotDTO>)lotService.GetLots();

            //Assert
            Assert.IsTrue(expected.SequenceEqual(actual, new LotDtoEqualityComparer()));
        }
Esempio n. 4
0
        public List <LotDTO> ConvertToLotDTO(ICollection <Lot> lotsDAL)
        {
            List <LotDTO> lotsDTO = new List <LotDTO>();

            foreach (var item in lotsDAL)
            {
                LotDTO lotDTO = new LotDTO
                {
                    ID          = item.ID,
                    Apartment   = item.Apartment,
                    Description = item.Description,
                    Flour       = item.Flour,
                    House       = item.House,
                    IsReserved  = item.IsReserved,
                    IsSold      = item.IsSold,
                    Price       = item.Price,
                    RoomsCount  = item.RoomsCount,
                    Square      = item.Square,
                    Address     = ConvertToAddressDTO(item.Address),
                    Photos      = ConvertToPhotoDTO(item.Photos)
                };
                lotsDTO.Add(lotDTO);
            }
            return(lotsDTO);
        }
        public async Task EditLotAsync_EditExistingLot_LotUpdated()
        {
            var newLot = new LotDTO()
            {
                BeginDate    = DateTime.Now,
                EndDate      = DateTime.Now.AddDays(2),
                InitialPrice = 10,
                Name         = "Lot 3",
                LotId        = 2,
                UserName     = "******",
                Category     = new CategoryDTO()
                {
                    CategoryId = 1
                }
            };
            var oldLot = new Lot()
            {
                BeginDate    = DateTime.Now.AddDays(5),
                EndDate      = DateTime.Now.AddDays(10),
                InitialPrice = 10,
                Name         = "Lot 3",
                LotId        = 2,
                UserId       = 1,
                CategoryId   = 1
            };

            _mockUnitWork.Setup(x => x.Lots.GetAsync(oldLot.LotId)).ReturnsAsync(oldLot);
            _mockUnitWork.Setup(x => x.Categories.GetAsync(newLot.Category.CategoryId)).ReturnsAsync(new Category());
            _mockUnitWork.Setup(x => x.Lots.Update(It.IsAny <Lot>()));

            await _service.EditLotAsync(newLot);

            _mockUnitWork.Verify(x => x.Lots.Update(It.IsAny <Lot>()));
        }
Esempio n. 6
0
        public void EditLotTest()
        {
            StubUnitOfWork uow = new StubUnitOfWork();

            CreateEditService createEditService = new CreateEditService(uow);

            Category category = uow.Categories.GetAll().FirstOrDefault();
            Lot      lot      = uow.Lots.GetAll().FirstOrDefault();

            LotDTO tempLot = new LotDTO()
            {
                Id           = lot.Id,
                Name         = "Test Update",
                StartPrice   = 333,
                CurrPrice    = 333,
                BuyNowPrice  = 3333,
                IsAllowed    = false,
                IsOpen       = false,
                CategoryName = category.Name,
                Description  = "qwe",
            };

            createEditService.EditLot(tempLot);

            lot = uow.Lots.Get(lot.Id);

            Assert.IsTrue(lot.Name == tempLot.Name);
            Assert.IsTrue(lot.StartPrice == tempLot.StartPrice);
            Assert.IsTrue(lot.CurrPrice == tempLot.CurrPrice);
            Assert.IsTrue(lot.BuyNowPrice == tempLot.BuyNowPrice);
            Assert.IsTrue(lot.IsAllowed == tempLot.IsAllowed);
            Assert.IsTrue(lot.IsOpen == tempLot.IsOpen);
            Assert.IsTrue(lot.Description == tempLot.Description);
            Assert.IsTrue(lot.Category.Name == tempLot.CategoryName);
        }
Esempio n. 7
0
        /// <summary>
        /// Creates a new Lot object and a Bid if exists from provided LotDTO object.
        /// </summary>
        internal static (Lot lot, Bid bid) LotAndBidFromLotDto(LotDTO lotDto)
        {
            if (lotDto == null)
            {
                return(null, null);
            }
            Lot lot = new Lot()
            {
                Id          = lotDto.Id,
                Name        = lotDto.Name,
                Description = lotDto.Description,
                Image       = lotDto.Image,
                ExpireDate  = lotDto.ExpireDate,
                StartPrice  = lotDto.StartPrice,
                SellerId    = lotDto.SellerId
            };
            Bid bid = null;

            if (lotDto.BidderId != null)
            {
                bid = new Bid()
                {
                    Id = lotDto.Id, BidderId = lotDto.BidderId, BidPrice = lotDto.CurrentPrice
                };
                lot.WasBidOn = true;
            }
            return(lot, bid);
        }
Esempio n. 8
0
        /// <summary>
        /// Creates a new LotDTO object from provided Lot object.
        /// </summary>
        internal static LotDTO LotDtoFromLot(Lot lot)
        {
            if (lot == null)
            {
                return(null);
            }
            var lotDto = new LotDTO()
            {
                Id             = lot.Id,
                Name           = lot.Name,
                Description    = lot.Description,
                Image          = lot.Image,
                ExpireDate     = lot.ExpireDate,
                SellerId       = lot.SellerId,
                SellerNickname = lot.Seller.Nickname,
                StartPrice     = lot.StartPrice
            };

            if (lot.WasBidOn)
            {
                lotDto.CurrentPrice   = lot.CurrentBid.BidPrice;
                lotDto.BidderId       = lot.CurrentBid.BidderId;
                lotDto.BidderNickname = lot.CurrentBid.Bidder.Nickname;
            }
            else
            {
                lotDto.CurrentPrice = lot.StartPrice;
            }
            return(lotDto);
        }
        public string DeclineLot(LotView lot)
        {
            var    mapper = new MapperConfiguration(cfg => cfg.CreateMap <LotView, LotDTO>()).CreateMapper();
            LotDTO lotDTO = mapper.Map <LotView, LotDTO>(lot);

            return(service.DeclineLot(lotDTO));
        }
        public void CreateLot(LotDTO lot)
        {
            using (Database)
            {
                if (lot.StartPrice > lot.BuyNowPrice)
                {
                    throw new ValidationException("Start price cant be higher than buy now price");
                }

                Category categoryField = Database.Categories.Find(x => x.Name == lot.CategoryName).FirstOrDefault();
                if (categoryField == null)
                {
                    throw new ItemNotFoundException("Category doesnt exist");
                }

                var mapper = new MapperConfiguration(cfg => cfg.CreateMap <LotDTO, Lot>());
                Lot tmpLot = mapper.CreateMapper().Map <LotDTO, Lot>(lot);

                tmpLot.CategoryId = categoryField.Id;
                tmpLot.Category   = categoryField;

                Database.Lots.Create(tmpLot);
                Database.Save();
            }
        }
Esempio n. 11
0
        public void Create(string userId, LotDTO lotDTO)
        {
            User user = IdentityDb.UserManager.FindById(userId);

            if (user == null)
            {
                throw new ItemNotExistInDbException("Cannot find user", userId);
            }
            if (lotDTO == null)
            {
                throw new ArgumentNullException("lotDTO");
            }
            lotDTO.Category = new CategoryDTO();
            Mapper.Map <User>(new UserDTO());

            Mapper.Map <Category>(new CategoryDTO());
            Mapper.Map <Bid>(new BidDTO());

            Mapper.Map <Status>(new StatusDTO());
            //      lotDTO.IdOwner = userId;    //TODO remove comment
            Lot lot = Mapper.Map <Lot>(lotDTO);

            //lot.Owner = new User();
            Database.Lots.Create(Mapper.Map <Lot>(lot));
            Database.Save();
        }
Esempio n. 12
0
        public ActionResult Edit(LotModel model)
        {
            var categories = GetCategories();

            model.Categories = GetSelectListItems(categories);
            model.CreatorId  = HttpContext.User.Identity.GetUserId();

            if (ModelState.IsValid)
            {
                Int32.TryParse(model.SelectedCategoryId, out int selectedId);

                LotDTO lotDTO = new LotDTO
                {
                    Id           = model.Id,
                    Name         = model.Name,
                    Description  = model.Description,
                    StartPrice   = model.StartPrice,
                    BidRate      = model.BidRate,
                    CurrentPrice = model.StartPrice,
                    CreatorId    = model.CreatorId,
                    Category     = categoryService.GetCategory(selectedId),
                    UserId       = HttpContext.User.Identity.GetUserId(),
                };

                lotService.Edit(lotDTO);

                return(RedirectToAction("UserLotsListing"));
            }

            return(View("Edit", model));
        }
Esempio n. 13
0
 public async Task AddLot(Guid tenderGuid, LotDTO lotDTO)
 {
     throw new NotImplementedException();
     ////TODO
     //var tender = await Context.Tenders.FirstOrDefaultAsync(m => m.Guid == tenderGuid);
     //var mapper = new LotMapper();
     //var lot = mapper.Map(lotDTO);
     //tender.Lots.Add(lot);
     //await Context.SaveChangesAsync();
 }
Esempio n. 14
0
        public async Task <Result> EditLotAsync(LotDTO lotDTO)
        {
            var lot = await Database.Lots.Get(lotDTO.Id);

            lot.StartPrice = lotDTO.StartPrice;
            Database.Lots.Update(lot);
            await Database.SaveAsync();

            return(new Result(true, $"", ""));
        }
        public async Task <IHttpActionResult> CreateLotAsync(LotDTO lot)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            lot.UserName = User.Identity.Name;
            var createdLot = await _lotsService.CreateLotAsync(lot);

            return(Created(Request.RequestUri + "/" + createdLot?.LotId, createdLot));
        }
        public void LotCreateTest_CreateLotWithInitPriceLessThenZero_BLValidationExceptionThrown()
        {
            //arrange
            LotDTO lot = new LotDTO {
                InitialPrice = -1, Id = 1, BeginDate = DateTime.Now.AddMinutes(1), EndDate = DateTime.Now.AddDays(1)
            };

            //act

            //assert
            Assert.Throws <BLValidationException>(() => _service.CreateLot(lot), "Lot price must be greater than zero.");
        }
        private LotResults GetAdditiveLotResults(LotDTO oldLot, Lot newLot)
        {
            _loadCount.AddRead(EntityTypes.AdditiveLot);

            var product = _newContextHelper.GetProduct(oldLot.tblProduct.ProdID);

            if (product == null)
            {
                Log(new CallbackParameters(oldLot, CallbackReason.AdditiveProductNotLoaded)
                {
                    Product = product
                });
                return(null);
            }
            if (product.AdditiveProduct == null)
            {
                if (product.ChileProduct != null)
                {
                    Log(new CallbackParameters(oldLot, CallbackReason.ExpectedAdditiveProductButFoundChile)
                    {
                        Product = product
                    });
                }
                else if (product.PackagingProduct != null)
                {
                    Log(new CallbackParameters(oldLot, CallbackReason.ExpectedAdditiveProductButFoundPackaging)
                    {
                        Product = product
                    });
                }
                return(null);
            }

            newLot.ProductionStatus      = LotProductionStatus.Produced;
            newLot.QualityStatus         = LotQualityStatus.Released;
            newLot.ProductSpecComplete   = true;
            newLot.ProductSpecOutOfRange = false;
            SetLotHoldStatus(oldLot.LotStat, newLot);
            SetIdentifiable(newLot, oldLot);

            return(new LotResults
            {
                AdditiveLot = LoadAttributes(new AdditiveLot
                {
                    LotDateCreated = newLot.LotDateCreated,
                    LotDateSequence = newLot.LotDateSequence,
                    LotTypeId = newLot.LotTypeId,
                    Lot = newLot,
                    AdditiveProductId = product.AdditiveProduct.Id
                }, oldLot)
            });
        }
Esempio n. 18
0
        public ActionResult BidsForLot(int lotId)
        {
            LotService ls     = new LotService();
            LotDTO     lotDto = new LotDTO();

            lotDto.BidsForLot = (List <BidDTO>)ls.AllBidsForLot(lotId);

            var config     = new MapperConfiguration(cfg => cfg.CreateMap <BidDTO, BidsForLotViewModel>());
            var mapper     = new Mapper(config);
            var bidsForLot = mapper.Map <List <BidsForLotViewModel> >(lotDto.BidsForLot);

            return(View(bidsForLot));
        }
        private static void SetIdentifiable(Lot newLot, LotDTO oldLot)
        {
            var deserialized = SerializableLot.Deserialize(oldLot.Serialized);

            if (deserialized != null)
            {
                if (deserialized.LotIdentifiable != null)
                {
                    newLot.EmployeeId = deserialized.LotIdentifiable.EmployeeKey.EmployeeKeyId;
                    newLot.TimeStamp  = deserialized.LotIdentifiable.TimeStamp;
                }
            }
        }
        private LotResults GetChileLotResults(LotDTO oldLot, Lot newLot, SerializableLot deserializedLot)
        {
            _loadCount.AddRead(EntityTypes.ChileLot);

            var product = _newContextHelper.GetProduct(oldLot.tblProduct.ProdID);

            if (product == null)
            {
                Log(new CallbackParameters(oldLot, CallbackReason.ChileProductNotLoaded));
                return(null);
            }
            if (product.ChileProduct == null)
            {
                if (product.AdditiveProduct != null)
                {
                    Log(new CallbackParameters(oldLot, CallbackReason.ExpectedChileProductButFoundAdditive)
                    {
                        Product = product
                    });
                }
                else if (product.PackagingProduct != null)
                {
                    Log(new CallbackParameters(oldLot, CallbackReason.ExpectedChileProductButFoundPackaging)
                    {
                        Product = product
                    });
                }
                return(null);
            }

            var chileProduct = _newContextHelper.GetChileProduct(oldLot.tblProduct.ProdID);

            if (chileProduct == null)
            {
                throw new Exception("Could not find ChileProduct with AttributeRanges.");
            }

            List <LotAttributeDefect> lotAttributeDefects;
            var newChileLot = _createChileLotHelper.CreateChileLot(oldLot, newLot, deserializedLot, chileProduct, _newContextHelper.AttributesNames.Values, out lotAttributeDefects);

            if (newChileLot == null)
            {
                return(null);
            }

            return(new LotResults
            {
                ChileLot = newChileLot,
                LotAttributeDefects = lotAttributeDefects
            });
        }
Esempio n. 21
0
        private PickedInventory CreatePickedInventory(DateTime entryDate, LotDTO lot)
        {
            _loadCount.AddRead(EntityTypes.PickedInventory);

            var identifiable = lot.tblOutgoingInputs.Cast <IEmployeeIdentifiableDTO>().ToList();

            identifiable.Add(lot);

            int?     employeeID;
            DateTime?timeStamp;

            identifiable.GetLatest(out employeeID, out timeStamp);

            if (timeStamp == null)
            {
                Log(new CallbackParameters(CallbackReason.PickedInventoryUndeterminedTimestamp)
                {
                    Lot = lot
                });
                return(null);
            }

            employeeID = employeeID ?? _newContextHelper.DefaultEmployee.EmployeeId;
            if (employeeID == _newContextHelper.DefaultEmployee.EmployeeId)
            {
                Log(new CallbackParameters(CallbackReason.PickedInventoryUsedDefaultEmployee)
                {
                    Lot        = lot,
                    EmployeeId = employeeID.Value
                });
            }

            var dateCreated = entryDate.Date;
            var sequence    = PickedInventoryKeyHelper.Singleton.GetNextSequence(dateCreated);

            var pickedInventory = new PickedInventory
            {
                EmployeeId = employeeID.Value,
                TimeStamp  = timeStamp.Value,

                DateCreated  = dateCreated,
                Sequence     = sequence,
                PickedReason = PickedReason.Production,
                Archived     = true,
            };

            pickedInventory.Items = CreatePickedInventoryItems(pickedInventory, lot.tblOutgoingInputs).ToList();

            return(pickedInventory);
        }
Esempio n. 22
0
        /// <summary>
        /// Async method for updating lot.
        /// </summary>
        /// <param name="lot">The lot DTO.</param>
        /// <returns>The Task.</returns>
        /// <exception cref="ArgumentNullException">Thrown if lot is null.</exception>
        /// <exception cref="ArgumentException">Thrown if image can't be processed and saved.</exception>
        /// <exception cref="NotFoundException">Thrown if lot not found in DB.</exception>
        /// <exception cref="ValidationException">Thrown if lot validation failed.</exception>
        public async Task EditLotAsync(LotDTO lot)
        {
            if (lot == null)
            {
                throw new ArgumentNullException(nameof(lot), "Lot is null.");
            }
            var oldLot = await _unitOfWork.Lots.GetAsync(lot.LotId);

            if (oldLot == null)
            {
                throw new NotFoundException("Lot not found.");
            }
            if ((lot.EndDate - lot.BeginDate).TotalHours < 1)
            {
                throw new ValidationException("Auction duration can not be less than 1 hour.");
            }
            var category = await _unitOfWork.Categories.GetAsync(lot.Category.CategoryId);

            if (category == null)
            {
                throw new ValidationException("Category not found.");
            }
            var oldLotDto = Mapper.Map <Lot, LotDTO>(oldLot);

            if (oldLotDto.Status != AuctionStatus.New)
            {
                if (oldLotDto.BeginDate != lot.BeginDate)
                {
                    throw new ValidationException("Can't edit auction begin date after it has started.");
                }
                if (oldLotDto.EndDate != lot.EndDate && lot.EndDate < DateTime.UtcNow)
                {
                    throw new ValidationException("Auction end date must be higher than current date.");
                }
            }
            if (lot.Image != null)
            {
                try
                {
                    lot.ImageUrl = ImageHandler.WriteImageToFile(lot.Image);
                }
                catch (ExternalException e)
                {
                    throw new ArgumentException("Processing image error.", nameof(lot.Image), e);
                }
            }
            lot.InitialPrice = oldLot.InitialPrice;
            _unitOfWork.Lots.Update(Mapper.Map <LotDTO, Lot>(lot, oldLot));
            await _unitOfWork.SaveAsync();
        }
Esempio n. 23
0
        public ActionResult LotInformation(LotViewModel lotViewModel)
        {
            LotService bs     = new LotService();
            LotDTO     lotDto = new LotDTO();

            lotDto.BidsForLot = (List <BidDTO>)bs.AllBidsForLot(lotViewModel.LotId);

            var config     = new MapperConfiguration(cfg => cfg.CreateMap <BidDTO, BidsForLotViewModel>());
            var mapper     = new Mapper(config);
            var bidsForLot = mapper.Map <List <BidsForLotViewModel> >(lotDto.BidsForLot);

            lotViewModel.BidsForLot = (List <BidsForLotViewModel>)bidsForLot;
            return(View(lotViewModel));
        }
        public ActionResult EditLot(int id, [FromForm] LotDTO lot)
        {
            if (id != lot.Id)
            {
                return(BadRequest());
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }



            if (lot.Image != null)
            {
                if (!lot.Image.ContentType.Contains("image"))
                {
                    return(BadRequest("Invalid image format."));
                }

                try
                {
                    lot.ImageUrl = ImageHandler.SaveImage(lot.Image, _environment);
                }
                catch (Exception)
                {
                    return(BadRequest("Image upload error."));
                }
            }


            try
            {
                _lotService.UpdateLot(lot);
            }
            catch (Exception ex)
            {
                if (_lotService.GetLot(id) == null)
                {
                    return(NotFound());
                }
                else
                {
                    return(BadRequest(ex.Message));
                }
            }
            return(NoContent());
        }
Esempio n. 25
0
        /// <summary>
        /// Async method for creating lot.
        /// </summary>
        /// <param name="lot">The lot DTO.</param>
        /// <returns>The Task, containing created lot DTO.</returns>
        /// <exception cref="ArgumentNullException">Thrown if lot is null.</exception>
        /// <exception cref="ValidationException">Thrown if lot validation failed.</exception>
        /// <exception cref="ArgumentException">Thrown if image can't be processed and saved.</exception>
        public async Task <LotDTO> CreateLotAsync(LotDTO lot)
        {
            if (lot == null)
            {
                throw new ArgumentNullException(nameof(lot), "Lot is null.");
            }
            if (lot.BeginDate < DateTime.UtcNow || lot.EndDate < DateTime.UtcNow || lot.BeginDate > lot.EndDate)
            {
                throw new ValidationException("Incorrect date.");
            }
            if ((lot.EndDate - lot.BeginDate).TotalHours < 1)
            {
                throw new ValidationException("Auction duration can not be less than 1 hour.");
            }
            if (lot.InitialPrice <= 0)
            {
                throw new ValidationException("Price must be greater than zero.");
            }
            var user = (await _unitOfWork.UserProfiles.FindAsync(x => x.Name == lot.UserName)).Items.FirstOrDefault();

            if (user == null)
            {
                throw new ValidationException("User not found.");
            }
            var category = await _unitOfWork.Categories.GetAsync(lot.Category.CategoryId);

            if (category == null)
            {
                throw new ValidationException("Category not found.");
            }
            var newLot = Mapper.Map <LotDTO, Lot>(lot);

            if (lot.Image != null)
            {
                try
                {
                    newLot.ImageUrl = ImageHandler.WriteImageToFile(lot.Image);
                }
                catch (ExternalException e)
                {
                    throw new ArgumentException("Processing image error.", nameof(lot.Image), e);
                }
            }
            newLot.UserId = user.UserProfileId;
            _unitOfWork.Lots.Create(newLot);
            await _unitOfWork.SaveAsync();

            return(Mapper.Map <Lot, LotDTO>(await _unitOfWork.Lots.GetAsync(newLot.LotId)));
        }
Esempio n. 26
0
        public async Task <Result> CreateLot(LotDTO lotDTO)
        {
            if (lotDTO != null)
            {
                Lot lot     = Mapper.Map <LotDTO, Lot>(lotDTO);
                var profile = await Database.Profiles.Get(lotDTO.Seller.Id);

                lot.Seller = profile;
                Database.Lots.Create(lot);
                await Database.SaveAsync();

                return(new Result(true, $"Lot {lotDTO.Name} is created", ""));
            }
            throw new ArgumentNullException("lotDTO is null");
        }
        //TODO

        public void EditLot(LotDTO lot)
        {
            using (Database)
            {
                Category categoryField = Database.Categories.Find(x => x.Name == lot.CategoryName).FirstOrDefault();

                var mapper = new MapperConfiguration(cfg => cfg.CreateMap <LotDTO, Lot>());

                Lot tmpLot = mapper.CreateMapper().Map <LotDTO, Lot>(lot);

                tmpLot.Category = categoryField;

                Database.Lots.Update(tmpLot);
                Database.Save();
            }
        }
Esempio n. 28
0
        public void EditLot(LotDTO newLot)
        {
            if (newLot == null)
            {
                throw new ArgumentNullException();
            }
            var lot = database.Lots.Get(newLot.Id);

            if (lot == null)
            {
                throw new NotFoundException();
            }

            lot.BiddingEnd = newLot.BiddingEnd;
            database.Lots.Update(lot);
        }
Esempio n. 29
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 }));
        }
Esempio n. 30
0
        public async Task <ActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(await new Task <ActionResult>(() => new HttpStatusCodeResult(HttpStatusCode.BadRequest)));
            }
            LotDTO lots = MarketService.GetLots(null).First();

            if (lots == null)
            {
                return(await new Task <ActionResult>(() => new HttpStatusCodeResult(HttpStatusCode.NotFound)));
            }

            await MarketService.DeleteLotAsync(id.Value);

            return(RedirectToAction("Profile"));
        }