private async Task LoadClients()
        {
            var clientList = await _clientEndpoint.GetAllClients();

            Clients = new BindingList <ClientModel>(clientList);
        }
예제 #2
0
        public async Task FillCheckedIn()
        {
            bool clientRegistered = false;

            string[] names = Client.Split(null);
            ErrorMessage = "";

            List <ClientModel> allClients = await _clientEndpoint.GetAllClients();

            foreach (ClientModel client in allClients)
            {
                if (client.FirstName == names[0] && client.LastName == names[1])
                {
                    clientRegistered = true;
                    Phone            = client.Phone;
                }
            }

            if (Client?.Length > 0 && clientRegistered == false)
            {
                ErrorMessage = "Error! You need to register client first!";
                return;
            }

            List <CheckInModel> allCheckedIns = await _checkInEndpoint.GetAllCheckIns();

            allCheckedIns = allCheckedIns.OrderByDescending(x => x.CreatedDate).ToList();

            CheckInModel checkedIn = allCheckedIns.Where(x => x.Client == Client).FirstOrDefault();

            if (checkedIn != null && checkedIn.IsCheckedOut == false)
            {
                Client             = checkedIn.Client;
                Id                 = checkedIn.Id;
                Phone              = checkedIn.Phone;
                SelectedRoomType   = checkedIn.RoomType;
                SelectedRoomNumber = checkedIn.RoomNumber;
                RoomTypes          = new BindingList <string> {
                    checkedIn.RoomType
                };
                RoomNumbers = new BindingList <int> {
                    checkedIn.RoomNumber
                };
                RoomCapacity = checkedIn.RoomCapacity;
                RoomPrice    = checkedIn.RoomPrice;
                DateIn       = checkedIn.DateIn;
                DateOut      = checkedIn.DateOut;
                StayDays     = checkedIn.StayDays;
                GuestNumber  = checkedIn.GuestNumber;
            }
            else
            {
                Id        = 0;
                RoomTypes = new BindingList <string> {
                    "single", "double", "triple", "quad"
                };
                RoomNumbers  = new BindingList <int>();
                RoomCapacity = 0;
                RoomPrice    = 0;
                DateIn       = DateTime.Now;
                DateOut      = DateTime.Now;
                StayDays     = 0;
                GuestNumber  = 0;
            }
        }