public async Task <ActionResult <ReceiptDto> > AddBasketItem(Guid basketId, BasketItemForCreationDto basketItem)
        {
            var basket = await _basketRepo.GetBasket(basketId);

            if (basket == null)
            {
                return(NotFound("Basket not found"));
            }
            if (basket.Status != Data.Entities.Enums.BasketStatus.Active)
            {
                return(Conflict("Cannot add items to a closed basket"));
            }
            if (basketItem.Item == null)
            {
                return(BadRequest("Item not specified"));
            }
            var item = await _itemsRepo.GetItemBySKU(basketItem.Item.SKU);

            if (item == null)
            {
                return(NotFound("Item not found"));
            }

            var basketItemEntity = _mapper.Map <Data.Entities.BasketItem>(basketItem);

            await _basketRepo.AddToBasket(basketItemEntity, basketId, item.Id);

            await _basketRepo.Save();

            var basketEntity = await _basketRepo.GetFullBasket(basketId);

            return(Ok(_checkoutService.CreateReceipt(_mapper.Map <ICollection <Models.BasketItemDto> >(basketEntity.BasketItems), basketEntity.PosId)));
        }
        public async Task <ActionResult <BasketDto> > Checkout(Guid basketId)
        {
            var basketEntity = await _basketRepo.GetFullBasket(basketId);

            if (basketEntity == null)
            {
                return(NotFound("Basket not found"));
            }
            if (basketEntity.Status != Data.Entities.Enums.BasketStatus.Active)
            {
                return(Conflict("Cannot checkout a closed basket"));
            }

            var receipt = _checkoutService.CreateReceipt(_mapper.Map <ICollection <BasketItemDto> >(basketEntity.BasketItems), basketEntity.PosId);

            _basketRepo.CheckoutBasket(basketEntity, receipt.TotalPrice, _mapper.Map <ICollection <Data.Entities.ReceiptItem> >(receipt.Items));
            await _basketRepo.Save();

            return(Ok(receipt));
        }