Пример #1
0
        public async Task <ActionResult <BidDTO> > EditBid(EditBidRequest editBidRequest)
        {
            Response <BidDTO> response = await this.bidsManager.EditBid(editBidRequest).ConfigureAwait(false);

            if (response.IsOperationSucceeded)
            {
                return(response.DTOObject);
            }
            return(this.StatusCode(StatusCodes.Status304NotModified, response.SuccessOrFailureMessage));
        }
Пример #2
0
        public async Task <ActionResult <BidDTO> > EditBid(EditBidRequest editBidRequest)
        {
            AuthorizationResult authorizationResult = await this.authorizationService.AuthorizeAsync(User, editBidRequest.BidId, PolicyNames.BidOwnerPolicy).ConfigureAwait(false);

            if (!authorizationResult.Succeeded)
            {
                return(this.StatusCode(StatusCodes.Status403Forbidden));
            }

            Response <BidDTO> response = await this.bidsManager.EditBid(editBidRequest).ConfigureAwait(false);

            if (response.IsOperationSucceeded)
            {
                return(response.DTOObject);
            }
            return(this.StatusCode(StatusCodes.Status304NotModified, response.SuccessOrFailureMessage));
        }
Пример #3
0
        public async Task <Response <BidDTO> > EditBid(EditBidRequest editBidRequest)
        {
            BidEntity bid = await _context.Bids.Where(b => b.Id == editBidRequest.BidId).Include(bid => bid.Product).FirstOrDefaultAsync().ConfigureAwait(false);

            if (bid == null)
            {
                return(new Response <BidDTO>()
                {
                    DTOObject = null, IsOperationSucceeded = false, SuccessOrFailureMessage = BidNotFoundFailString
                });
            }

            bid.Product.Name        = editBidRequest.NewName ?? bid.Product.Name;
            bid.Product.Image       = editBidRequest.NewProductImage ?? bid.Product.Image;
            bid.Product.Description = editBidRequest.NewDescription ?? bid.Product.Description;
            bid.Category            = editBidRequest.NewCategory ?? bid.Category;
            bid.SubCategory         = editBidRequest.NewSubCategory ?? bid.SubCategory;

            try
            {
                _context.Bids.Update(bid);
                await _context.SaveChangesAsync().ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                return(new Response <BidDTO>()
                {
                    DTOObject = null, IsOperationSucceeded = false, SuccessOrFailureMessage = ex.Message
                });
            }
            BidDTO bidDTO = _mapper.Map <BidDTO>(bid);

            return(new Response <BidDTO>()
            {
                DTOObject = bidDTO, IsOperationSucceeded = true, SuccessOrFailureMessage = this.getSuccessMessage()
            });
        }
Пример #4
0
 public Task <Response <BidDTO> > EditBid(EditBidRequest editBidRequest)
 {
     throw new NotImplementedException();
 }