Пример #1
0
        private async void newAppointment(string GuesttName, string GuestCompany, string GuestPhoneNumber, DateTime MeetingStartDateTime, DateTime MeetingEndDateTime)
        {
            try
            {
                //Register new Appointment.

                string ccode = await VisitorAppHelper.GenerateIvCode();

                txtIvCode.Text = ccode;
                string InvitationCode = ccode;

                string LocationName = cmbMeetingLocation.SelectedItem.ToString();
                for (int i = 0; i < LocationIds.Count; i++)
                {
                    if (LocationName == Locations[i].ToString())
                    {
                        LocationId          = Convert.ToInt32(LocationIds[i].ToString());
                        FloorNo             = Convert.ToInt32(FloorNumber[i].ToString());
                        txbFloorNumber.Text = FloorNo.ToString();
                        break;
                    }
                }

                string staffIdno = "";

                var selectedIndex = cmbstaffIdNumber.SelectedIndex;
                staffIdno = cmbstaffIdNumber.Items[selectedIndex].ToString();
                for (int i = 0; i <= staffIds.Count - 1; i++)
                {
                    if (staffIdno == staffIdNumber[i].ToString())
                    {
                        staffId = Convert.ToInt32(staffIds[i].ToString());
                        break;
                    }
                }

                AppointmentDataPayload appointment = new AppointmentDataPayload();
                appointment.GuestName            = GuesttName;
                appointment.GuestCompanyName     = GuestCompany;
                appointment.GuestPhoneNumber     = GuestPhoneNumber;
                appointment.GuestEmail           = txtGuestEmail.Text.Trim();
                appointment.InvitationCode       = InvitationCode;
                appointment.HostStaffId          = staffId;
                appointment.CreatedByStaffId     = _activePage.UserStaffId;
                appointment.LocationId           = LocationId;
                appointment.CompanyId            = CompId;
                appointment.MeetingStartDateTime = MeetingStartDateTime;
                appointment.MeetingEndDateTime   = MeetingEndDateTime;
                appointment.Description          = txtDescription.Text + ". Added by " + _activePage.UserStaffId;
                appointment.Status = AppointmentStatus.Pending.ToString();//"Pending";

                ResponseMessage msgExist = await service.CheckIfAppointmentExistService(appointment);

                if (msgExist.ResponseStatusCode == System.Net.HttpStatusCode.NotFound)
                {
                    ResponseMessage msg = await service.RegisterNewAppointment(appointment);

                    //if (!string.IsNullOrEmpty(appointment.GuestEmail))
                    //{
                    ResponseMessage msgEmail = await service.EmailRegisterNewAppointment(appointment);

                    //}

                    if (msg.ResponseStatusCode == System.Net.HttpStatusCode.NotFound)
                    {
                        newVisitor();
                        MessageDialog ms = new MessageDialog("Successfully Registered");
                        ms.ShowAsync();
                        CreateBinding();
                        noted();
                        ClearAddNewAppointmentFields();
                        GridEditItemDetail.Visibility    = Visibility.Collapsed;
                        GridAddNewAppointment.Visibility = Visibility.Collapsed;
                    }
                    else
                    {
                        MessageDialog ms = new MessageDialog("Err: " + msg.Message);
                        ms.ShowAsync();
                    }
                }
                else
                {
                    MessageDialog ms = new MessageDialog("Err: " + msgExist.Message);
                    ms.ShowAsync();
                }
            }
            catch (Exception ex)
            {
                checkInternet();
                MessageDialog msg = new MessageDialog(ex.Message + " Void - newAppointment");
                //msg.ShowAsync();
            }
        }