示例#1
0
        public void CreateNewAppointmentAllValid()
        {
            Appointment appointment = BuildNewAppointment();
            bool        results     = false;

            results = _appMgr.CreateAppointmentByGuest(appointment);
            Assert.IsTrue(results);
        }
示例#2
0
 /// <summary>
 /// Eduardo Colon
 /// Created: 2019/04/23
 ///
 /// method to submit walkinappointment
 /// </summary>
 private void BtnSubmit_Click(object sender, RoutedEventArgs e)
 {
     if (cboFirstName.SelectedValue == null)
     {
         MessageBox.Show("Please select a first name.");
     }
     else if (cboLastName.SelectedValue == null)
     {
         MessageBox.Show("Please select a last name");
     }
     else if (cboEmail.SelectedValue == null)
     {
         MessageBox.Show("Please select an email");
     }
     else if (cboAppointmentTypes.SelectedValue == null)
     {
         MessageBox.Show("Please select an appointment type");
     }
     else if (dtpikStart.SelectedDate == null)
     {
         MessageBox.Show("Please select a start date");
     }
     else if (dtpikEnd.SelectedDate == null)
     {
         MessageBox.Show("Please select an end date");
     }
     else
     {
         Appointment newAppointment = new Appointment()
         {
             AppointmentType = (string)cboAppointmentTypes.SelectedValue,
             StartDate       = dtpikStart.SelectedDate.Value,
             EndDate         = dtpikEnd.SelectedDate.Value,
             GuestID         = _guests.Where(g => g.FirstName == (string)cboFirstName.SelectedValue &&
                                             g.LastName == (string)cboLastName.SelectedValue && g.Email == (string)cboEmail.SelectedValue).First().GuestID,
             Description = ""
         };
         try
         {
             _appointmentManager.CreateAppointmentByGuest(newAppointment);
             MessageBox.Show("Appointment created!");
             this.DialogResult = true;
             this.Close();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message + Environment.NewLine + ex.StackTrace);
         }
     }
 }
        public ActionResult Create(AppointmentModel appointment)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    Guest  guest = new Guest();
                    string email = User.Identity.Name;
                    guest = _guestManager.RetrieveGuestByEmail(email);
                    Appointment appt = new Appointment()
                    {
                        AppointmentType = appointment.AppointmentType,
                        Description     = appointment.Description,
                        StartDate       = appointment.StartDate,
                        EndDate         = appointment.StartDate.AddDays(1),
                        GuestID         = guest.GuestID
                    };
                    if (_apptManager.CreateAppointmentByGuest(appt))
                    {
                        TempData["success"] = new SuccessViewModel(
                            Title: "an Appointment!",
                            dateTime: appointment.StartDate.ToShortDateString(),
                            type: appointment.AppointmentType,
                            time: appointment.Time,
                            ButtonMessage: "Go to Account",
                            ReturnController: "MyAccount",
                            ReturnAction: "Index"
                            );

                        return(RedirectToAction("Index", "Success"));
                    }
                }
                catch (Exception ex)
                {
                    TempData["error"] = new ErrorViewModel(
                        Title: "Appointment",
                        Message: "We could not schedule you an appoinment for " + appointment.AppointmentType,
                        ExceptionMessage: ex.Message,
                        ButtonMessage: "Back to Amenities",
                        ReturnController: "Amenitites",
                        ReturnAction: "Index"
                        );

                    return(RedirectToAction("Index", "Error"));
                }
            }
            return(View(appointment));
        }
示例#4
0
        /// <summary>
        /// Wes Richardson
        /// Create: 2019/04/18
        ///
        /// Helper Method that creates the appointment
        /// </summary>
        /// <param name="cavm"></param>
        /// <param name="length"></param>

        private void CreateAppointment(CreateAppointmentViewModel cavm, int length, string type)
        {
            try
            {
                Appointment appointment = new Appointment
                {
                    AppointmentType = type,
                    StartDate       = cavm.StartDay.AddHours(cavm.StartTime),
                    EndDate         = cavm.StartDay.AddHours(cavm.StartTime + length),
                    Description     = cavm.Description,
                    GuestID         = _guestID
                };
                if (appointment.Description == null)
                {
                    appointment.Description = "";
                }
                _appointmentMgr.CreateAppointmentByGuest(appointment);
            }
            catch (Exception ex)
            {
                ViewBag.errorMessage = ex.Message;
            }
        }