Exemple #1
0
 // PUT api/<controller>/5
 public void Put(int id, [FromBody] AppointmentViewModel value)
 {
     try
     {
         AppointmentViewModel appt = value;
         using (CallTraxEntities callTraxDb = new CallTraxEntities())
         {
             Appointment appointment = callTraxDb.Appointments.Where(a => a.AppointmentId == appt.Id).FirstOrDefault();
             if (appointment != null)
             {
                 appointment.LocationId          = appt.LocationId;
                 appointment.ConsultantId        = appt.ConsultantId;
                 appointment.StartDateTime       = appt.StartDateTime.ToLocalTime();
                 appointment.EndDateTime         = appt.EndDateTime.ToLocalTime();
                 appointment.CustomerFirstName   = appt.FirstName;
                 appointment.CustomerLastName    = appt.LastName;
                 appointment.CustomerPhoneNumber = appt.Phone;
                 appointment.ServiceCategoryId   = appt.ServiceId;
                 appointment.Note = appt.Note;
                 callTraxDb.SaveChanges();
             }
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemple #2
0
 // POST api/<controller>
 public void Post([FromBody] AppointmentViewModel value)
 {
     try
     {
         AppointmentViewModel appt = value;
         using (CallTraxEntities callTraxDb = new CallTraxEntities())
         {
             Appointment newappt = new Appointment
             {
                 StartDateTime       = value.StartDateTime.ToLocalTime(),
                 EndDateTime         = value.EndDateTime.ToLocalTime(),
                 LocationId          = value.LocationId,
                 ConsultantId        = value.ConsultantId,
                 ServiceCategoryId   = appt.ServiceId,
                 CustomerFirstName   = value.FirstName,
                 CustomerLastName    = value.LastName,
                 CustomerPhoneNumber = value.Phone,
                 Note = value.Note
             };
             callTraxDb.Appointments.Add(newappt);
             callTraxDb.SaveChanges();
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemple #3
0
 // DELETE api/<controller>/5
 public void Delete(int id)
 {
     try
     {
         using (CallTraxEntities callTraxDb = new CallTraxEntities())
         {
             Appointment appt = callTraxDb.Appointments.Where(a => a.AppointmentId == id).FirstOrDefault();
             if (appt != null)
             {
                 callTraxDb.Appointments.Remove(appt);
                 callTraxDb.SaveChanges();
             }
         }
     }
     catch (Exception)
     {
         throw;
     }
 }