public async Task <IActionResult> Reservation(ReservationModel reservationModel)
        {
            if (ModelState.IsValid)
            {
                TblPerson tblPerson = new TblPerson
                {
                    FirstName    = reservationModel.FirstName,
                    LastName     = reservationModel.LastName,
                    EmailAddress = reservationModel.EmailAddress,
                    PhoneNumber  = reservationModel.PhoneNumber,
                    StreetNumber = reservationModel.StreetNumber,
                    StreetName   = reservationModel.StreetName,
                    City         = reservationModel.City,
                    PostalCode   = reservationModel.PostalCode,
                    Country      = reservationModel.Country,
                };
                await _context.TblPerson.AddAsync(tblPerson);

                TblReservation tblReservation = new TblReservation
                {
                    PersonId           = tblPerson.PersonId,
                    RoomNumber         = reservationModel.RoomNumber,
                    ExpectedArriveDate = reservationModel.ExpectedArrivalDate,
                    ExpectedLeaveDate  = reservationModel.ExpectedLeaveDate,
                    ReservationNotes   = reservationModel.Notes,
                };
                await _context.TblReservation.AddAsync(tblReservation);

                await _context.SaveChangesAsync();

                return(Redirect("/"));
            }
            return(View());
        }
        public async Task <IActionResult> DeleteHouseKeeping(int id)
        {
            var houseKeeping = await _context.TblRoomHouseKeeping.FindAsync(id);

            _context.TblRoomHouseKeeping.Remove(houseKeeping);

            await _context.SaveChangesAsync();

            return(Redirect("~/HouseKeeping"));
        }
        public async Task <IActionResult> CompleteMaintenance(int id)
        {
            var maintenance = await _context.TblRoomMaintenance.FindAsync(id);

            maintenance.EndDatetime = DateTime.Now;

            _context.Update(maintenance);

            await _context.SaveChangesAsync();

            return(Redirect("~/Maintenance"));
        }
        public async Task <IActionResult> EditReservation(ReservationModel reservationModel)
        {
            if (ModelState.IsValid)
            {
                TblPerson tblPerson = new TblPerson
                {
                    PersonId     = reservationModel.PersonID,
                    FirstName    = reservationModel.FirstName,
                    LastName     = reservationModel.LastName,
                    City         = reservationModel.City,
                    Country      = reservationModel.Country,
                    EmailAddress = reservationModel.EmailAddress,
                    PhoneNumber  = reservationModel.PhoneNumber,
                    PostalCode   = reservationModel.PostalCode,
                    StreetName   = reservationModel.StreetName,
                    StreetNumber = reservationModel.StreetNumber,
                };

                TblReservation tblReservation = new TblReservation
                {
                    ReservationId      = reservationModel.ReservationID,
                    PersonId           = tblPerson.PersonId,
                    ExpectedArriveDate = reservationModel.ExpectedArrivalDate,
                    ExpectedLeaveDate  = reservationModel.ExpectedLeaveDate,
                    RoomNumber         = reservationModel.RoomNumber,
                    ReservationNotes   = reservationModel.Notes
                };

                _context.Update(tblPerson);
                _context.Update(tblReservation);

                await _context.SaveChangesAsync();

                return(Redirect("~/Concierge/Reservations"));
            }

            ViewData["RoomNumber"] = new SelectList(_context.TblRooms.Where(s => s.RoomStatus == 0), "RoomNumber", "RoomNumber");
            return(View(reservationModel));
        }
        public async Task <IActionResult> NewEmployee(EmployeeModel employeeModel)
        {
            var person = _context.TblPerson.Where(x => x.EmailAddress == employeeModel.EmailAddress).ToList();

            ViewData["Error"] = "";
            foreach (var x in person)
            {
                if (x.EmailAddress == employeeModel.EmailAddress)
                {
                    ViewData["Position"] = new SelectList(_context.LkpPositionTypes.Where(s => s.IsActive == true), "PositionId", "Description");
                    ViewData["Error"]    = "The email address for username is already taken.";
                    return(View());
                }
            }

            if (ModelState.IsValid)
            {
                TblPerson tblPerson = new TblPerson
                {
                    FirstName    = employeeModel.FirstName,
                    LastName     = employeeModel.LastName,
                    EmailAddress = employeeModel.EmailAddress,
                    PhoneNumber  = employeeModel.PhoneNumber,
                    StreetNumber = employeeModel.StreetNumber,
                    StreetName   = employeeModel.StreetName,
                    City         = employeeModel.City,
                    PostalCode   = employeeModel.PostalCode,
                    Country      = employeeModel.Country,
                };
                await _context.TblPerson.AddAsync(tblPerson);

                TblEmployee tblEmployee = new TblEmployee
                {
                    EmployeeId             = tblPerson.PersonId,
                    EmergencyContactName   = employeeModel.EmergencyContactName,
                    EmergencyContactNumber = employeeModel.EmergencyContactNumber,
                };
                await _context.TblEmployee.AddAsync(tblEmployee);

                TblPosition tblPosition = new TblPosition
                {
                    EmployeeId = tblEmployee.EmployeeId,
                    PositionId = employeeModel.Position,
                    StartDate  = DateTime.Now,
                };
                await _context.TblPosition.AddAsync(tblPosition);

                var user = new ApplicationUser {
                    UserName = employeeModel.EmailAddress, Email = employeeModel.EmailAddress
                };
                var result = await _userManager.CreateAsync(user, "Password@123");

                if (result.Succeeded)
                {
                    _userManager.AddToRoleAsync(user, _context.LkpPositionTypes.Find(employeeModel.Position).Description.ToString()).Wait();
                }

                await _context.SaveChangesAsync();

                return(Redirect("/Admin/"));
            }
            ViewData["Position"] = new SelectList(_context.LkpPositionTypes.Where(s => s.IsActive == true), "PositionId", "Description");
            return(View());
        }