I am creating a Asp.Net MVC Rest Api. There are two things that I have. One is I have a user and other is booking. Results are returned according to the user type. If User has access to city A means he can see bookings for city A only. I want to search bookings based on 3 parameters
- City
- Location
- Date OR
- BookingId Either top 3 or the bookingId alone + user parameters.
As the user object is dependent on the booking how should be my RestApi model Class designed.
Should it be like
public class Booking : User{}
OR
public class Booking{ public User user { get;set; } }
User Details are required for searching the bookings. User refers to the person who is logged in and using the system and searching the bookings.
RestApi method looks like the following below:
[HttpPost]
public HttpResponseMessage GetBookings(Booking booking)
{}
I want to know the advantages and disadvantages of the approach and suggest me if there is any better way possible.
Based on discussions[edit]
How logical it will be If I accept another parameter for user in my api.Client who is calling my Api has to pass it as a parameter.Now code looks like this?
[HttpPost]
public HttpResponseMessage GetBookings(Booking booking,User user)
{}
Booking
is not a subtype ofUser
, at least it shouldn't be.Booking
a specific type ofUser
? No, aBooking
has anUser