public IActionResult UpdateAuction(int auctionId)
        {
            DetailsAuctionViewModel currentAuction = _businessService.GetAuctionById(auctionId);
            UpdateAuctionViewModel  viewModel      = _businessService.SetUpdateViewModel(currentAuction);

            return(View(viewModel));
        }
        public async Task <IActionResult> Update([FromRoute] string id, [FromBody] UpdateAuctionViewModel viewModel)
        {
            var auctionId = IdentityBase.FromExistingId <AuctionId>(id);
            var command   = new UpdateAuctionCommand(auctionId, viewModel.Name, viewModel.AuctionDate);
            await _commandBus.ExecuteAsync(command);

            return(Ok());
        }
Exemple #3
0
        public UpdateAuctionViewModel SetUpdateViewModel(DetailsAuctionViewModel currentAuction)
        {
            UpdateAuctionViewModel viewModel = new UpdateAuctionViewModel
            {
                Id          = currentAuction.Id,
                Title       = currentAuction.Title,
                Description = currentAuction.Description,
                StartPrice  = currentAuction.StartPrice
            };

            return(viewModel);
        }
Exemple #4
0
        public DetailsAuctionViewModel UpdateAuction(UpdateAuctionViewModel newValues, DetailsAuctionViewModel oldValues)
        {
            DetailsAuctionViewModel viewModel = new DetailsAuctionViewModel
            {
                Id              = oldValues.Id,
                Title           = newValues.Title,
                Description     = newValues.Description,
                StartDateString = oldValues.StartDateString,
                EndDateString   = oldValues.EndDateString,
                GroupCode       = _apiKey,
                StartPrice      = newValues.StartPrice,
                CreatedBy       = _userService.GetCurrentUserName()
            };

            return(viewModel);
        }
Exemple #5
0
        public UpdateAuctionViewModel GetUpdateViewModel(TestAuctionViewModel currentAuction)
        {
            UpdateAuctionViewModel viewModel = new UpdateAuctionViewModel
            {
                Id          = currentAuction.UpdateAuctionViewModel.Id,
                Title       = currentAuction.UpdateAuctionViewModel.Title,
                Description = currentAuction.UpdateAuctionViewModel.Description,
                //StartDateString = currentAuction.UpdateAuctionViewModel.StartDateString,
                //EndDateString = currentAuction.UpdateAuctionViewModel.EndDateString,
                GroupCode  = _apiKey,
                StartPrice = currentAuction.UpdateAuctionViewModel.StartPrice,
                CreatedBy  = _userService.GetCurrentUserName(),
            };

            return(viewModel);
        }
Exemple #6
0
        public AuctionModel MakeAuctionApiReady(UpdateAuctionViewModel viewModel)
        {
            AuctionModel model = new AuctionModel
            {
                AuktionID   = viewModel.Id.ToString(),
                Titel       = viewModel.Title,
                Beskrivning = viewModel.Description,
                StartDatum  = viewModel.StartDateString,
                SlutDatum   = viewModel.EndDateString,
                Gruppkod    = _apiKey,
                Utropspris  = viewModel.StartPrice.ToString(),
                SkapadAv    = viewModel.CreatedBy
            };

            return(model);
        }
Exemple #7
0
        public IActionResult UpdateAuction(TestAuctionViewModel currentAuction)
        {
            if (ModelState.IsValid)
            {
                UpdateAuctionViewModel viewModel = _businessService.GetUpdateViewModel(currentAuction);

                AuctionModel model = _businessService.MakeAuctionApiReady(viewModel);

                HttpResponseMessage response = _businessService.UpdateAuction(model);

                if (response.IsSuccessStatusCode == true)
                {
                    return(RedirectToAction("ViewAuctionDetails", "Auction", new { auctionId = viewModel.Id, message = "Auction was successfully updated" }));
                }

                return(RedirectToAction("ViewAuctionDetails", "Auction", new { auctionId = viewModel.Id, message = "Auction has not been updated" }));
            }

            return(View(currentAuction));
        }