0
votes

I have a request object for a POST in a ServiceStack service that looks like this:

[Route("/jtip/cases/search", "POST")]
public class FindAgencyCases : IReturn<List<AgencyCaseResponse>>
{
    public int? AgencyId { get; set; }
    public string AgencyCaseNumber { get; set; }
    public int? ServiceId { get; set; }
    public string IndividualFirstName { get; set; }
    public string IndividualLastName { get; set; }
    public string CompanyName { get; set; }
    public string LicenseNumber { get; set; }
    public string LicenseState { get; set; }
    public string IndividualType { get; set; }
    public DateTime? RequestStartDate { get; set; }
    public DateTime? RequestEndDate { get; set; }
    public string Status { get; set; }
    public int? ResultsLimit { get; set; }
}

The values for AgencyId, ServiceId, etc need to come from dropdown lists. This DTO doesn't care how it gets those values, but I need to provide collections for my agencies, services, etc.

Because this is a request object, I can't grab my lists from the database and send them to the client. So how would I go about getting the lists for my dropdowns (in an HTML form) that contain the values to populate the above request DTO? I'm I overlooking something really obvious?

1
How are you serving up the HTML form in general? Is it an ASP.NET web form, MVC view, Razor view delivered via ServiceStack, plain static HTML file, etc.?Mike Mertsock
My consumer is ASP.Net MVC using the ServiceStack C# client. At this point I'm attempting to just create an empty request, which brings back a response containing an object with the collections for all of my dropdown lists, which will be called when the form is drawn.Don Fitz
What do you mean by "Because this is a request object, I can't grab my lists from the database and send them to the client"? What is the reason for not getting the response data from DB?Ermias Y

1 Answers

2
votes

Why not simply create another request / route that lists the available agencies and services?

[Route("/jtip/cases/agencies", "GET")]
public class AgencyListRequest : IReturn<List<Agency>>
{
}

public class Agency {
  public int Id { get; set; }
  public string Name { get; set; }
}

[Route("/jtip/cases/services", "GET")]
public class ServiceListRequest : IReturn<List<Service>>
{
}

public class Service {
  public int Id { get; set; }
  public string Name { get; set; }
}