コード例 #1
0
ファイル: ProductLogic.cs プロジェクト: Petrica3696/Licenta
        public void UpdateBid(Guid id, UpdateBid product)
        {
            Product productToUpdate = _repository.GetByFilter <Product>(p => p.Id == id);

            if (productToUpdate == null)
            {
                return;
            }

            productToUpdate.FinalPrice = product.FinalPrice;
            productToUpdate.WinnerId   = product.WinnerId;
            if (product.Deadline >= DateTime.Today)
            {
                productToUpdate.Deadline = product.Deadline;
            }

            _repository.Update(productToUpdate);
            _repository.Save();

            Wishlist wishlist = _repository.GetByFilter <Wishlist>(p => p.ProductId == id.ToString() && p.UserId == product.WinnerId);

            if (wishlist == null)
            {
                var newWish = new Wishlist
                {
                    Id        = Guid.NewGuid(),
                    UserId    = product.WinnerId,
                    ProductId = id.ToString()
                };

                _repository.Insert(newWish);
                _repository.Save();
            }


            Recommendations recommendations = _repository.GetByFilter <Recommendations>(p => p.UserId == product.WinnerId && p.CategoryId == productToUpdate.CategoryId);

            if (recommendations == null)
            {
                var newBid = new Recommendations
                {
                    Id         = Guid.NewGuid(),
                    CategoryId = productToUpdate.CategoryId,
                    UserId     = product.WinnerId,
                    Bids       = 0
                };

                _repository.Insert(newBid);
                _repository.Save();
            }
            else
            {
                recommendations.Bids++;

                _repository.Update(recommendations);
                _repository.Save();
            }
        }
コード例 #2
0
 private async void SetupHub()
 {
     _updateDelegate = new UpdateBid(UpdateBidMethod);
     _updateButtonsDelegate = new UpdateButtons(UpdateButtonsMethod);
     _hubConnection = new Microsoft.AspNet.SignalR.Client.HubConnection("http://localhost:1331/");
     _auctionProxy = _hubConnection.CreateHubProxy("AuctionHub");
     _auctionProxy.Subscribe("UpdateBid").Received += UpdateBid_auctionProxy;
     _auctionProxy.Subscribe("CloseBid").Received += CloseBid_auctionProxy;
     _auctionProxy.Subscribe("CloseBidWin").Received += CloseBidWin_auctionProxy;
     await _hubConnection.Start();
 }
コード例 #3
0
 private async void SetupHub()
 {
     _updateDelegate = new UpdateBid(UpdateBidMethod);
     _updateButtonsDelegate = new UpdateButtons(UpdateButtonsMethod);
     _hubConnection = new HubConnection("http://192.168.1.148:1331/");
     _auctionProxy = _hubConnection.CreateHubProxy("AuctionHub");
     _auctionProxy.Subscribe("UpdateBid").Received += UpdateBid_auctionProxy;
     _auctionProxy.Subscribe("CloseBid").Received += CloseBid_auctionProxy;
     _auctionProxy.Subscribe("CloseBidWin").Received += CloseBidWin_auctionProxy;
     await _hubConnection.Start();
 }
コード例 #4
0
        private async void SetupHub()
        {
            _updateDelegate        = UpdateBidMethod;
            _updateButtonsDelegate = UpdateButtonsMethod;
            _hubConnection         = new HubConnection("http://localhost:4558");
            _auctionProxy          = _hubConnection.CreateHubProxy("AuctionHub");
            _auctionProxy.Subscribe("updateBid").Received   += OnUpdateBid;
            _auctionProxy.Subscribe("CloseBid").Received    += OnCloseBid;
            _auctionProxy.Subscribe("CloseBidWin").Received += OnCloseBidWin;

            await _hubConnection.Start().ConfigureAwait(false);
        }
コード例 #5
0
 public IActionResult UpdateBid([FromRoute] Guid id, [FromBody] UpdateBid productDto)
 {
     _productLogic.UpdateBid(id, productDto);
     return(NoContent());
 }