예제 #1
0
        public Task <HttpResponseMessage> GetClientByIdPhotos(int clientId)
        {
            HttpResponseMessage response = new HttpResponseMessage();

            try
            {
                //var clientViewModel = Mapper.Map<Client, ClientViewModel>(_service.GetDataByIdPhones(clientId));
                var clientViewModel = _service.GetDataByIdPhones(clientId);
                if (clientViewModel != null)
                {
                    response = Request.CreateResponse(HttpStatusCode.OK, clientViewModel);
                }
                else
                {
                    response = Request.CreateResponse(HttpStatusCode.BadRequest, "Cliente não encontrado.");
                }
            }
            catch (Exception ex)
            {
                response = Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message);
            }

            var tsc = new TaskCompletionSource <HttpResponseMessage>();

            tsc.SetResult(response);
            return(tsc.Task);
        }