public async Task <IActionResult> Add([FromBody] BasketBase data) { if (!int.TryParse(User.Claims?.FirstOrDefault(p => p.Type == ClaimTypes.Sid)?.Value, out var userid)) { return(Unauthorized()); } await BasketService.Add(userid, data.GoodsId, data.Count); return(Ok()); }
/// <summary>Register service method with a service binder with or without implementation. Useful when customizing the service binding logic. /// Note: this method is part of an experimental API that can change or be removed without any prior notice.</summary> /// <param name="serviceBinder">Service methods will be bound by calling <c>AddMethod</c> on this object.</param> /// <param name="serviceImpl">An object implementing the server-side handling logic.</param> public static void BindService(grpc::ServiceBinderBase serviceBinder, BasketBase serviceImpl) { serviceBinder.AddMethod(__Method_GetBasketById, serviceImpl == null ? null : new grpc::UnaryServerMethod <global::GrpcBasket.BasketRequest, global::GrpcBasket.CustomerBasketResponse>(serviceImpl.GetBasketById)); serviceBinder.AddMethod(__Method_UpdateBasket, serviceImpl == null ? null : new grpc::UnaryServerMethod <global::GrpcBasket.CustomerBasketRequest, global::GrpcBasket.CustomerBasketResponse>(serviceImpl.UpdateBasket)); }
/// <summary>Creates service definition that can be registered with a server</summary> /// <param name="serviceImpl">An object implementing the server-side handling logic.</param> public static grpc::ServerServiceDefinition BindService(BasketBase serviceImpl) { return(grpc::ServerServiceDefinition.CreateBuilder() .AddMethod(__Method_GetBasketById, serviceImpl.GetBasketById) .AddMethod(__Method_UpdateBasket, serviceImpl.UpdateBasket).Build()); }