Ejemplo n.º 1
0
        public ActionResult FreeRoomReport(FreeRoomReportModel model)
        {
            var sql =
                "select rm.* from Rooms rm " +
                "where not exists(" +
                "select * from Reservations rs " +
                "where rs.RoomId = rm.Id and " +
                "(rs.ArrivalDate < '{0}' and rs.DepartureDate > '{1}' or " +
                "rs.ArrivalDate < '{0}' and rs.DepartureDate > '{1}' or rs.ArrivalDate >= '{0}' and rs.DepartureDate <= '{1}'));";

            var from = DateTime.Parse(model.From);
            var to = DateTime.Parse(model.To);

            var formatSql = string.Format(sql, from.ToString("yyyy-MM-dd HH:mm:ss"), to.ToString("yyyy-MM-dd HH:mm:ss"));
            var rooms = db.Rooms.SqlQuery(formatSql).ToList();
            return View(rooms);
        }
Ejemplo n.º 2
0
        public ActionResult FreeRoomReport(FreeRoomReportModel model)
        {
            var sql =
                "select rm.* from Rooms rm " +
                "where not exists(" +
                "select * from Reservations rs " +
                "where rs.RoomId = rm.Id and " +
                "(rs.ArrivalDate < '{0}' and rs.DepartureDate > '{1}' or " +
                "rs.ArrivalDate < '{0}' and rs.DepartureDate > '{1}' or rs.ArrivalDate >= '{0}' and rs.DepartureDate <= '{1}'));";

            var from = DateTime.Parse(model.From);
            var to   = DateTime.Parse(model.To);

            var formatSql = string.Format(sql, from.ToString("yyyy-MM-dd HH:mm:ss"), to.ToString("yyyy-MM-dd HH:mm:ss"));
            var rooms     = db.Rooms.SqlQuery(formatSql).ToList();

            return(View(rooms));
        }