public override async Task <AllCustomersReply> AllCustomers(AllCustomersReq request, ServerCallContext context)
        {
            var reply = new AllCustomersReply {
                Success = true
            };

            try
            {
                var data = await _customerService.SearchAsync(c => true, request.Page, request.PageSize);

                data.ForEach(o => reply.Data.Add(new CustomerArg
                {
                    Id        = o.Id.ToString(),
                    FirstName = o.FirstName,
                    LastName  = o.LastName,
                    CreatedBy = o.CreatedBy,
                    CreatedAt = Google.Protobuf.WellKnownTypes.Timestamp.FromDateTimeOffset(o.CreatedAt),
                    UpdatedBy = o.UpdatedBy,
                    UpdatedAt = Google.Protobuf.WellKnownTypes.Timestamp.FromDateTimeOffset(o.UpdatedAt)
                }));
            }
            catch (Exception ex)
            {
                reply.Success = false;
                reply.Message = ex.Message;
            }

            return(reply);
        }
Esempio n. 2
0
 public override AsyncUnaryCall <AllCustomersReply> AllCustomersAsync(AllCustomersReq request, Metadata headers = null, DateTime?deadline = null, CancellationToken cancellationToken = default)
 {
     return(base.AllCustomersAsync(request, headers, deadline, cancellationToken));
 }