/// <summary>
        /// Create reservation into database, this method can be used for create only.
        /// </summary>
        /// <param name="reservation"></param>
        /// <returns></returns>
        private async Task <bool> CreateReservationInDataBase(ReservationRequest reservation, IdentityUser user)
        {
            try
            {
                var sitting = await SetSittingType(reservation);

                //Get all reservations from database, use AsNoTracking method to avoid exception.
                var currentReservations = await _context.ReservationRequests.AsNoTracking().ToListAsync();

                //Check if the input reservation can be made using CanMakeReservation method.
                var canMakeReservation = CanMakeReservation(currentReservations, null, reservation, sitting);
                if (!canMakeReservation)
                {
                    return(false);
                }

                if (reservation.Email == "*****@*****.**" && reservation.GuestName == "default" && reservation.Mobile == "0400000000")
                {
                    if (user != null)
                    {
                        var guest = await _context.People.FindAsync(user.Id);

                        reservation.PersonId  = user.Id;
                        reservation.Email     = user.Email;
                        reservation.GuestName = guest.FullName;
                        reservation.Mobile    = guest.Mobile;
                    }
                }
                reservation.ReservationSource = ReservationSource.Online;
                reservation.TimeStamp         = DateTime.Now;
                reservation.ReferenceNo       = Guid.NewGuid();

                var reservationDate =
                    await _context.ReservationDates.FirstOrDefaultAsync(r => r.Date.Date.Equals(reservation.StartDateTime.Date));

                if (reservationDate == null)
                {
                    reservationDate = new ReservationDate {
                        Date = reservation.StartDateTime.Date
                    };
                    _context.ReservationDates.Add(reservationDate);
                }
                reservationDate.Reservations.Add(reservation);
                _context.ReservationRequests.Add(reservation);

                await _context.SaveChangesAsync();

                return(true);
            }
            catch (Exception ex)
            {
                _logger.Error(ex.Message);
                throw new Exception(ex.Message);
            }
        }
        /// <summary>
        /// Edit reservation in database, this method can be used for edit only.
        /// </summary>
        /// <param name="reservation"></param>
        /// <returns></returns>
        private async Task <bool> EditReservationInDataBase(ReservationRequest reservation, IdentityUser user)
        {
            try
            {
                var sitting = await SetSittingType(reservation);

                //Get all reservations from database, use AsNoTracking method to avoid exception.
                var currentReservations = await _context.ReservationRequests.AsNoTracking().ToListAsync();

                var oldReservation = currentReservations.Find(r => r.Id.Equals(reservation.Id));

                //Check if the input reservation can be made using CanMakeReservation method.
                var canMakeReservation = CanMakeReservation(currentReservations, oldReservation, reservation, sitting);
                if (!canMakeReservation)
                {
                    return(false);
                }

                //Check is the current operator the manager or member.
                var isManager = false;
                if (reservation.Email == "*****@*****.**" && reservation.GuestName == "default" && reservation.Mobile == "0400000000")
                {
                    var roles = await _context.Roles.ToListAsync();

                    var userRoles = await _context.UserRoles.ToListAsync();

                    var manager = roles.Find(r => r.Name.ToLower().Equals("manager"));
                    if (manager != null)
                    {
                        isManager = userRoles.Find(u => u.UserId.Equals(user.Id)).RoleId == manager.Id;
                    }
                }

                //Keep the current reservation same as old reservation.
                reservation.ReservationSource = oldReservation.ReservationSource;
                reservation.TimeStamp         = oldReservation.TimeStamp;
                reservation.ReferenceNo       = oldReservation.ReferenceNo;
                reservation.PersonId          = oldReservation.PersonId;
                reservation.GuestName         = oldReservation.GuestName;
                reservation.Email             = oldReservation.Email;
                reservation.Mobile            = oldReservation.Mobile;

                var reservationDate =
                    await _context.ReservationDates.FirstOrDefaultAsync(r => r.Date.Date.Equals(reservation.StartDateTime.Date));

                if (reservationDate == null)
                {
                    reservationDate = new ReservationDate {
                        Date = reservation.StartDateTime.Date
                    };
                    _context.ReservationDates.Add(reservationDate);
                }

                //If table is unassigned, create one and save it to database, else update the existing one.
                var table = await _context.Tables.FirstOrDefaultAsync(t => t.ReservationId.Equals(reservation.Id));

                if (table == null)
                {
                    table = new Table
                    {
                        TableType         = reservation.TableType,
                        ReservationDateId = reservation.Id,
                        ReservationDate   = reservationDate,
                        Reservation       = reservation
                    };
                    reservation.Table   = table;
                    reservation.TableId = table.Id;
                    _context.Tables.Add(table);
                }
                else
                {
                    //If current operator is manager, he is allowed to change the table type in the table entity.
                    //Otherwise, the customer should only follow the table type read from database.
                    if (isManager)
                    {
                        table.TableType = reservation.TableType;
                    }
                    else
                    {
                        reservation.TableType = table.TableType;
                    }
                    reservation.Table   = table;
                    reservation.TableId = table.Id;
                }

                reservationDate.Reservations.Add(reservation);
                _context.ReservationRequests.Update(reservation);
                await _context.SaveChangesAsync();

                return(true);
            }
            catch (Exception ex)
            {
                _logger.Error(ex.Message);
                throw new Exception(ex.Message);
            }
        }