Beispiel #1
0
        public override async Task <ProductResponse> AddProduct(ProductRequest request, ServerCallContext context)
        {
            if (!Guid.TryParse(request.Product.StoreId, out Guid storeID))
            {
                throw new ArgumentException($"invalid store id {request.Product.StoreId}");
            }

            var product = new Shared.DAL.Product
            {
                StoreID     = storeID,
                Name        = request.Product.Name,
                Price       = request.Product.Price,
                Description = request.Product.Description,
            };
            var entry = await this.repo.AddProductAsync(product);

            return(new ProductResponse
            {
                Products =
                {
                    new Product
                    {
                        Name = entry.Name,
                        Id = entry.ID.ToString(),
                        StoreId = entry.StoreID.ToString(),
                        Price = Convert.ToInt32(entry.Price),
                        Created = Timestamp.FromDateTime(entry.Created),
                    }
                }
            });
        }
 public async Task <StoreResponse> GetStoresAsync(Shared.DAL.Product product) =>
 await Client.GetStoreAsync(new StoreRequest
 {
     Product = new Product
     {
         Id      = product.ID.ToString(),
         StoreId = product.StoreID.ToString()
     }
 });
 public async Task <ProductResponse> RemoveProductAsync(Shared.DAL.Product product) => throw new NotImplementedException();