Esempio n. 1
0
        public HttpResponseMessage statuschange(HttpRequestMessage request, int id, string statuschange = null)
        {
            // tbAppointment appointment = new tbAppointment();
            tbAppointment UpdatedAppointment = null;

            tbAppointment appointment = appointmentRepo.Get().Where(a => a.ID == id).FirstOrDefault();

            appointment.Status = statuschange;
            UpdatedAppointment = appointmentRepo.UpdatewithObj(appointment);
            List <tbAppointment> appointments = appointmentRepo.Get().Where(a => a.Status == "ACCEPTED" && a.Counter < appointment.Counter).ToList();
            string time1 = appointment.AppointmentDateTime.Value.ToLongTimeString();

            //tbAppointment mama = appointmentRepo.Get().Where(a => a.ID == 4).FirstOrDefault();
            //string time2 = mama.AppointmentDateTime.Value.ToLongTimeString();
            //TimeSpan duration = DateTime.Parse(time1).Subtract(DateTime.Parse(time2));
            foreach (var acceptlist in appointments)
            {
                string   time2    = acceptlist.AppointmentDateTime.Value.ToLongTimeString();
                TimeSpan duration = DateTime.Parse(time1).Subtract(DateTime.Parse(time2));
                TimeSpan comTime  = new TimeSpan(01, 00, 00);
                if (duration >= comTime)
                {
                    acceptlist.Status = "CANCEL";
                    appointmentRepo.UpdatewithObj(acceptlist);
                }
                //  string t1 = "01:00:00";
                //   TimeSpan t2 = DateTime.Parse(t1);
                // if (duration.ToString().Equals(t1))
                //{
                //     acceptlist.Status = "CANCEL";
                //      appointmentRepo.UpdatewithObj(acceptlist);
                //  }
            }
            return(request.CreateResponse <tbAppointment>(HttpStatusCode.OK, UpdatedAppointment));
        }
        public HttpResponseMessage changestatus(HttpRequestMessage request, int id, string status)
        {
            bool          result      = false;
            tbAppointment appointment = appointmentRepo.Get().Where(a => a.ID == id).FirstOrDefault();

            if (appointment != null)
            {
                if (status == "BOOKED")
                {
                    appointment.Status     = null;
                    appointment.IsWaiting  = true;
                    appointment.IsApproved = true;
                }
                else if (status == "WAITING")
                {
                    appointment.Status    = status;
                    appointment.IsWaiting = true; //updated
                }
                else if (status == "CHECKIN")
                {
                    appointment.IsWaiting = true;
                    appointment.IsCheckIn = true;
                    appointment.Status    = status;
                }
                else if (status == "CHECKOUT")
                {
                    appointment.IsWaiting = true;
                    appointment.IsCheckIn = true;
                    appointment.Status    = status;
                }
                else if (status == "CANCEL")
                {
                    appointment.Status       = "CANCEL";
                    appointment.IsDelByAdmin = true;
                    appointment.IsWaiting    = false;
                    appointment.IsCheckIn    = false;
                }
                else if (status == "SKIP")
                {
                    if (appointment.SkipCount == null)
                    {
                        appointment.SkipCount   = 1;
                        appointment.Position   += 5;
                        appointment.CreatedTime = DateTime.UtcNow.getLocalTime();
                    }
                    else
                    {
                        appointment.Status       = "CANCEL";
                        appointment.IsDelByAdmin = true;
                    }
                }

                result = appointmentRepo.UpdatewithObj(appointment) != null ? true : false;
            }
            return(request.CreateResponse <bool>(HttpStatusCode.OK, result));
        }
Esempio n. 3
0
 public Appointment GetAppointment(long ID)
 {
     return(_ar.Get(ID));
 }