public ResponseEnvelope <object> Response(ObterResponse response) { return(new ResponseEnvelope <object>() { Item = new { Titulo = "Titulo do post" } }); }
public ResponseEnvelope <List <dto.Banner> > Response(ObterResponse response) { var envelope = new ResponseEnvelope <List <dto.Banner> >(); envelope.HttpStatusCode = (HttpStatusCode)response.HttpStatusCode; if (envelope.Success) { foreach (var item in response.Banners) { envelope.Item.Add(new dto.Banner(item.Id, item.Imagem, item.Thumb, item.URL)); } } else { envelope.Error = new ErrorEnvelope { Messages = new List <string> { response.Erro } }; } return(envelope); }
public override Task <ObterResponse> ObterParaApp(ObterRequest request, ServerCallContext context) { var response = new ObterResponse(); try { var usuarioId = Guid.Parse(request.UsuarioId); var banners = servico.Obter(usuarioId); response.HttpStatusCode = (int)HttpStatusCode.OK; response.Banners.AddRange(banners); } catch (Exception ex) { response.HttpStatusCode = (int)HttpStatusCode.InternalServerError; response.Erro = ex.Message; } return(Task.FromResult(response)); }
public override Task <ObterResponse> Obter(ConsultaRequest request, ServerCallContext context) { var response = new ObterResponse(); try { var usuarioId = Guid.Parse(request.UsuarioId); var empresaId = Guid.Parse(request.EmpresaId); var parser = new PostObter(); var dtos = postServico.Obter(usuarioId, empresaId); response = parser.Response(dtos); } catch (Exception ex) { response.HttpStatusCode = (int)HttpStatusCode.InternalServerError; } return(Task.FromResult(response)); }