Exemplo n.º 1
0
        public override Task <CustomerResponse> GetCustomer(CustomerItemRequest request, ServerCallContext context)
        {
            var user = _kernel.GetEntity <User>(externalId: ParseUserID(id: request.Id));

            ValidateUserType(user);
            context.Status = new Status(StatusCode.OK, string.Empty);
            return(Task.FromResult(MapToResponse(user: user)));
        }
Exemplo n.º 2
0
        public async Task <HttpResponseMessage> GetItem([FromUri] CustomerItemRequest request)
        {
            HttpResponseMessage httpResponse = null;
            string uri    = Url.Link("CustomerItemApi", new { userName = request.userName });;
            string userId = request.userName;
            IResultServiceModel <CustomerItemResponse> response = new ResultServiceModel <CustomerItemResponse>();

            try
            {
                var rmCred = this.ValidateUserCredentials(request.userName);
                if (rmCred.Success)
                {
                    var rsmFile = this.mainService.GetCustomerFile(request.id, request.userName);

                    var file = new FilePOCO(rsmFile.Value);

                    response.OnSuccess(new CustomerItemResponse()
                    {
                        item = file
                    });
                }
                else
                {
                    response.OnError(rmCred.ErrorMessage, rmCred.ErrorCode);
                }
            }
            catch (Exception ex)
            {
                response.OnException(ex);
            }

            httpResponse = Request.CreateResponse <IResultServiceModel <CustomerItemResponse> >(HttpStatusCode.Created, response);
            httpResponse.Headers.Location = new Uri(uri);

            return(httpResponse);
        }