Good afternoon, can anyone help me to create a database procedure in SQL? To make a room reservation, I have to select a room and declare the DataEntry and the DataSaid.
What I want is if you make a reservation in room 1 between June 13th, 20th and June 14th, and then if someone wants to make another reservation in that room between June 13th, 06/14/2018, since this room already has a reservation on that day, I want a message to appear busy. Can someone help me?
Reservation table
public partial class Reserva
{
public int ID_Reserva { get; set; }
public int ID_Cliente { get; set; }
public int ID_Quarto { get; set; }
public System.DateTime DataEntrada { get; set; }
public Nullable<System.DateTime> DataSaida { get; set; }
public int NumeroPessoas { get; set; }
public Nullable<int> NumeroNoites { get; set; }
public Nullable<decimal> Preço { get; set; }
public string Observaçoes { get; set; }
public virtual Cliente Cliente { get; set; }
public virtual Quarto Quarto { get; set; }
}
Room Table
public partial class Quarto
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
public Quarto()
{
this.Reserva = new HashSet<Reserva>();
}
public int ID_Quarto { get; set; }
public string TipoQuarto { get; set; }
public string EstadoQuarto { get; set; }
public Nullable<decimal> PreçoQuarto { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<Reserva> Reserva { get; set; }
}