I have 2 tables in one database: first has an information about apatrments, second show what apartments have already booked: has ApatrmentIds from first one, and 2 dates: arrive and departure.
I need to show users what apartments are available to book. It means that user inputs date and apartments dates of book don't match.
Model of first table:
public class Apartment
{
public int ApartmentId { get; set;}
[Required]
public int Quantity { get; set; }
[Required]
public Classes Class { get; set; }
[Required]
public int Price { get; set; }
}
public enum Classes
{
Economy,
Standart,
Luxury
}
Model of second table:
public class Booked
{
public int BookedId { get; set;}
public int ApartmentId { get; set; }
public DateTime Start { get; set; }
public DateTime End { get; set; }
}
I tried to use linq, but i need to communicate between ApartmentId(key) of the first table and ApartmentId(not key) of the second.
How it would be better to do?
so what do you think is better to fixed it← Research. Again, there is a lot of material out there including many tutorials and relationships is usually covered early on in any of these sites. All you have to do is spend a little time reading. The above problem can be solved with a trivial amount of effort on your part.