public int BookSeats(CoreModels.BookingInfo bookSeats) { using (var database = new Database("BookMyShow")) { return(Convert.ToInt16(database.Insert("BookingInfo", "Id", bookSeats.Map <DataModels.BookingInfo>()))); } }
public CoreModels.SeatsInfo GetSeatsInfo(CoreModels.BookingInfo bookingInfo) { List <CoreModels.BookingInfo> bookedSeats = GetBookedSeats(bookingInfo); CoreModels.SeatsInfo seatsInfo = new CoreModels.SeatsInfo(); seatsInfo.PremiumSeats = new List <CoreModels.Seat>(); seatsInfo.StandardSeats = new List <CoreModels.Seat>(); CoreModels.Theater theater; List <string> unavailableSeats = new List <string>(); foreach (var bookedSeat in bookedSeats) { var seats = bookedSeat.SeatsBooked.Split(','); unavailableSeats.AddRange(seats); } using (var database = new Database("bookMyShow")) { theater = database.FirstOrDefault <DataModels.Theater>("select * from Theaters where Id=@0", bookingInfo.TheaterId).Map <CoreModels.Theater>(); } seatsInfo.NoOfPremiumRows = theater.NoOfPremiumRows; seatsInfo.NoOfStandardRows = theater.NoOfStandardRows; char row = 'A'; seatsInfo.PremiumSeats = CreateSeats(row, theater.NoOfPremiumRows, theater.NoOfSeatsPerRow, unavailableSeats); row = Convert.ToChar('A' + theater.NoOfPremiumRows); seatsInfo.StandardSeats = CreateSeats(row, theater.NoOfStandardRows, theater.NoOfSeatsPerRow, unavailableSeats); return(seatsInfo); }
public List <CoreModels.BookingInfo> GetBookedSeats(CoreModels.BookingInfo bookingInfo) { DataModels.BookingInfo dMbookingInfo = bookingInfo.Map <DataModels.BookingInfo>(); using (var database = new Database("BookMyShow")) { return(database.Fetch <DataModels.BookingInfo>("Select * from BookingInfo where MovieId=@0 AND TheaterId=@1 AND ShowDate=@2 AND ShowTime=@3", dMbookingInfo.MovieId, dMbookingInfo.TheaterId, dMbookingInfo.ShowDate, dMbookingInfo.ShowTime).MapCollection <List <DataModels.BookingInfo>, List <CoreModels.BookingInfo> >()); } }