public HttpResponseMessage GetValues() { try { List<ClientViewModelSearch> list = new List<ClientViewModelSearch>(); foreach (var i in _AppClient.FindAll()) { ClientViewModelSearch client = new ClientViewModelSearch(); client.ClientId = i.ClientId; client.Name = i.Name; client.Email = i.Email; client.DateRegister = i.DateRegister.ToString("dd/MM/yyyy"); list.Add(client); } return Request.CreateResponse(HttpStatusCode.OK,list); } catch (Exception e) { return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Error GetValues" + e.Message); } }
public HttpResponseMessage GetValue(int id) { try { var client = _AppClient.FindById(id); if (client != null) { ClientViewModelSearch model = new ClientViewModelSearch() { ClientId =client.ClientId, Name = client.Name, Email = client.Email, DateRegister = client.DateRegister.ToString("dd/MM/yyyy") }; return Request.CreateResponse(HttpStatusCode.OK, model); } else { return Request.CreateResponse(HttpStatusCode.NotFound, "Error not found Client"); } } catch (Exception e) { return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "error in Getvalue " + e.Message); } }