private async Task <ResponseMessagesDto> UpdateProductSellAsync(CreateProductSaleDto productSellDto)
        {
            var result = await _productSaleRepository.UpdateAsync(new ProductSell()
            {
                Id            = productSellDto.Id,
                Status        = productSellDto.Status,
                Description   = productSellDto.Description,
                SellingRate   = productSellDto.SellingRate,
                ShopProductId = productSellDto.ShopProductId,
            });

            if (result != null)
            {
                return(new ResponseMessagesDto()
                {
                    Id = result.Id,
                    SuccessMessage = AppConsts.SuccessfullyUpdated,
                    Success = true,
                    Error = false,
                });
            }
            return(new ResponseMessagesDto()
            {
                Id = 0,
                ErrorMessage = AppConsts.UpdateFailure,
                Success = false,
                Error = true,
            });
        }
        private async Task <ResponseMessagesDto> CreateProductSellAsync(CreateProductSaleDto productSellDto)
        {
            var productList = new List <ProductSell>();

            for (var x = 0; x < productSellDto.Quantity; x++)
            {
                var product = new ProductSell();
                product.Status        = productSellDto.Status;
                product.Description   = productSellDto.Description;
                product.SellingRate   = productSellDto.SellingRate;
                product.ShopProductId = productSellDto.ShopProductId;
                product.TenantId      = productSellDto.TenantId;
                productList.Add(product);
            }
            await _productSaleRepository.GetDbContext().AddRangeAsync(productList);

            //var result = await _productSaleRepository.InsertAsync(new ProductSell()
            //{
            //    Status = productSellDto.Status,
            //    SellingRate = productSellDto.SellingRate,
            //    ShopProductId = productSellDto.ShopProductId,
            //});


            await UnitOfWorkManager.Current.SaveChangesAsync();

            var shopProduct = await _shopProductRepository.GetAll()
                              .Where(i => i.Id == productSellDto.ShopProductId && i.Quantity > 0)
                              .SingleOrDefaultAsync();

            shopProduct.Quantity = shopProduct.Quantity - productSellDto.Quantity;
            await _shopProductRepository.UpdateAsync(shopProduct);

            if (productList[0].Id != 0)
            {
                return(new ResponseMessagesDto()
                {
                    Id = productList[0].Id,
                    SuccessMessage = AppConsts.SuccessfullyInserted,
                    Success = true,
                    Error = false,
                });
            }
            return(new ResponseMessagesDto()
            {
                Id = 0,
                ErrorMessage = AppConsts.InsertFailure,
                Success = false,
                Error = true,
            });
        }
        public async Task <ResponseMessagesDto> CreateOrEditAsync(CreateProductSaleDto productSellDto)
        {
            ResponseMessagesDto result;

            if (productSellDto.Id == 0)
            {
                result = await CreateProductSellAsync(productSellDto);
            }
            else
            {
                result = await UpdateProductSellAsync(productSellDto);
            }
            return(result);
        }