Esempio n. 1
0
        public static BasketLine ToDomain(this BasketLineForUpdateModel source)
        {
            if (source == null)
            {
                return(null);
            }

            return(new BasketLine
            {
                TicketAmount = source.TicketAmount
            });
        }
Esempio n. 2
0
        public async Task <ActionResult <BasketLineModel> > Put(Guid basketId,
                                                                Guid basketLineId,
                                                                [FromBody] BasketLineForUpdateModel basketLineForUpdate)
        {
            if (!await _mediator.Send(new BasketExistsQuery(basketId)))
            {
                return(NotFound());
            }

            var basketLine = await _mediator.Send(new GetBasketLineByIdQuery(basketLineId));

            if (basketLine == null)
            {
                return(NotFound());
            }

            basketLine.SetTicketAmount(basketLineForUpdate.TicketAmount);

            await _mediator.Send(new UpdateBasketLineCommand(basketLine));

            return(Ok(basketLine.ToModel()));
        }