Learning Path Details
Foundation in C#: Hotel Management App from Tim Corey
Description:
Module 9 of the Complete Foundation in C# Course Series, we put together all we have learned by planning and building a hotel management application to the minimum viable product (MVP) level. Tim's approach is "homework first", so at each stage, we are asked to complete the stage before we see how Tim would do it.
Key Takeaways:
By applying the WOULD framework in our planning, the execution of the minimum viable product becomes easier. We maintain a list of features to be added for future versions, and in the last section, we implement one by adding SQLite as a data access option in a manner that allows the end user to easily select the data storage.
Technologies Learned:
- .NET;
- .NET Core;
- .NET Core 3.1;
- .NET Standard;
- .NET Standard 2.0;
- ASP.NET Core Web Application (Razor Pages);
- C#;
- Class Library;
- Dapper;
- SQL;
- SQL Server Database Project;
- SQLite;
- WPF Application;
This learning resource was completed on 12/30/2021.
Find the Resource here:
Practice Projects
Hotel Management App
Description:
The homework from Module 9, Hotel Management App, of the Complete Foundation in C# Course Series from Tim Corey. We have been commissioned to create a hotel management application. We need a web portal that allows people to book an available room. We also need a desktop app for when they check in.
We need to create a minimum viable product (MVP) that will allow the customer to get going and to identify what features should be added later.
Technologies Used:
- .NET;
- .NET Core;
- .NET Core 3.1;
- .NET Core Web Application (Razor Pages);
- .NET Standard;
- .NET Standard 2.1;
- C#;
- Class Library;
- SQL;
- SQL Server Database Project;
- SQLite;
- WPF Application;
Find the Project here:
Code Snippet:
using System;
using System.Collections.Generic;
using System.Linq;
using HotelAppLibrary.Databases;
using HotelAppLibrary.Models;
namespace HotelAppLibrary.Data
{
public class SqlData : IDatabaseData
{
private readonly ISqlDataAccess _db;
private const string connectionStringName = "SqlDb";
public SqlData(ISqlDataAccess db)
{
_db = db;
}
public List<RoomTypeModel> GetAvailableRoomTypes(DateTime startDate, DateTime endDate)
{
return _db.LoadData<RoomTypeModel, dynamic>("dbo.spRoomTypes_GetAvailableTypes",
new { startDate, endDate },
connectionStringName,
true);
}
public void BookGuest(string firstName, string lastName, DateTime startDate, DateTime endDate, int roomTypeId)
{
GuestModel guest = _db.LoadData<GuestModel, dynamic>("dbo.spGuests_InsertGuest",
new { firstName, lastName },
connectionStringName,
true).First();
RoomTypeModel roomType = _db.LoadData<RoomTypeModel, dynamic>("SELECT * FROM dbo.RoomTypes where Id = @Id",
new { Id = roomTypeId },
connectionStringName,
false).First();
TimeSpan timeStaying = endDate.Date.Subtract(startDate.Date);
List<RoomModel> availableRooms = _db.LoadData<RoomModel, dynamic>("dbo.spRooms_GetAvailableRooms",
new { startDate, endDate, roomTypeId },
connectionStringName,
true);
_db.SaveData("dbo.spBookings_Insert",
new
{
roomId = availableRooms.First().Id,
guestId = guest.Id,
startDate,
endDate,
totalCost = timeStaying.Days * roomType.Price
},
connectionStringName,
true);
}
public List<BookingFullModel> SearchBookings(string lastName)
{
return _db.LoadData<BookingFullModel, dynamic>("dbo.spBookings_Search",
new { lastName, startDate = DateTime.Now.Date },
connectionStringName,
true);
}
public void CheckInGuest(int bookingId)
{
_db.SaveData("dbo.spBookings_CheckIn", new { Id = bookingId }, connectionStringName, true);
}
public RoomTypeModel GetRoomTypeById(int id)
{
return _db.LoadData<RoomTypeModel, dynamic>("dbo.spRoomTypes_GetById",
new { id },
connectionStringName,
true).FirstOrDefault();
}
}
}