Exemple #1
0
        protected void PopulateDDL()
        {
            try
            {
                string userID = User.Identity.GetUserId();
                using (CallTraxEntities callTraxDb = new CallTraxEntities())
                {
                    ClientUser user = callTraxDb.ClientUsers.Where(u => u.AspNetUserId == userID).FirstOrDefault();
                    if (user != null)
                    {
                        List <ClientLocation> locations = callTraxDb.ClientLocations.Where(l => l.ClientId == user.ClientId).ToList();
                        foreach (ClientLocation location in user.Client.ClientLocations)
                        {
                            ddlLocation.Items.Add(new ListItem {
                                Text = location.LocationName, Value = location.ClientLocationId.ToString()
                            });
                        }
                        List <Consultant> consultants = callTraxDb.Consultants.Where(c => c.ClientId == user.ClientId).ToList();
                        foreach (Consultant consultant in consultants)
                        {
                            ddlConsultant.Items.Add(new ListItem {
                                Text = consultant.ConsultantName, Value = consultant.ConsultantId.ToString()
                            });
                        }

                        PopulateServicesDDL(ddlConsultant.SelectedValue);
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #2
0
 protected void PopulateServicesDDL(string ConsultantId)
 {
     try
     {
         ddlService.Items.Clear();
         using (CallTraxEntities callTraxDb = new CallTraxEntities())
         {
             List <SessionTime> sessionList = callTraxDb.SessionTimes.Where(s => s.ConsultantId.ToString() == ddlConsultant.SelectedValue).ToList();
             foreach (SessionTime session in sessionList)
             {
                 ddlService.Items.Add(new ListItem(session.ServiceCategory.Name, session.ServiceCategory.ServiceCategoryId.ToString()));
             }
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemple #3
0
        public static DataTable GetData(string locationId, string consultantId, DateTime startDate, DateTime endDate)
        {
            DataTable dt;

            dt = new DataTable();

            try
            {
                dt.Columns.Add("start", typeof(DateTime));
                dt.Columns.Add("end", typeof(DateTime));
                dt.Columns.Add("name", typeof(string));
                dt.Columns.Add("id", typeof(string));
                dt.Columns.Add("color", typeof(string));


                using (CallTraxEntities callTraxDb = new CallTraxEntities())
                {
                    List <Appointment> appointments = callTraxDb.Appointments.Where(a => a.LocationId.ToString() == locationId && a.ConsultantId.ToString() == consultantId && a.StartDateTime >= startDate && a.EndDateTime <= endDate).ToList();
                    foreach (Appointment appointment in appointments)
                    {
                        DataRow dr;

                        dr          = dt.NewRow();
                        dr["id"]    = appointment.AppointmentId.ToString();
                        dr["start"] = appointment.StartDateTime;
                        dr["end"]   = appointment.EndDateTime;
                        dr["name"]  = $"{appointment.CustomerFirstName} {appointment.CustomerLastName}";
                        ;
                        dt.Rows.Add(dr);
                    }
                }

                dt.PrimaryKey = new DataColumn[] { dt.Columns["id"] };
            }
            catch (Exception)
            {
                //throw;
                //TODO:Log Error
            }

            return(dt);
        }
Exemple #4
0
 public static void MoveAppointment(long appointmentId, DateTime startDate, DateTime endDate)
 {
     try
     {
         using (CallTraxEntities callTraxDb = new CallTraxEntities())
         {
             Appointment app = callTraxDb.Appointments.Where(a => a.AppointmentId == appointmentId).FirstOrDefault();
             if (app != null)
             {
                 app.StartDateTime = startDate;
                 app.EndDateTime   = endDate;
                 callTraxDb.SaveChanges();
             }
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemple #5
0
 protected void SetLocationBussinessHours()
 {
     try
     {
         Session["BusinessBeginsHour"] = 9;
         Session["BusinessEndsHour"]   = 18;
         using (CallTraxEntities callTraxDb = new CallTraxEntities())
         {
             ClientLocation loc = callTraxDb.ClientLocations.Where(l => l.ClientLocationId.ToString() == ddlLocation.SelectedValue).FirstOrDefault();
             if (loc != null)
             {
                 Session["BusinessBeginsHour"] = (int)loc.BusinessBeginsHour;
                 Session["BusinessEndsHour"]   = (int)loc.BusinessEndsHour;
             }
         }
     }
     catch (Exception)
     {
         throw;
     }
 }