Example #1
0
        public IHttpActionResult Generate()
        {
            try
            {
                string   attendeesString = "Ramy Othman,Michael Eggers,Denys Tochkovyi,Benjamin Maertz,Moshe Schmidt,Ondrej Kelle,Christian Kaas,Markus Pfahlert,Carolin Maier";
                string[] subject         = new string[] { "Meeting", "Daily", "Gym", "Interview", "Reading", "Presentation", "Study" };
                string[] attendees       = attendeesString.Split(',');
                for (int i = 1; i <= 12; i++)
                {
                    int rand = new Random().Next(2, 6);
                    for (int j = 0; j <= rand; j++)
                    {
                        Data.Appointment app = new Data.Appointment();
                        int    randAtt       = new Random().Next(2, 6);
                        string strAtt        = "";
                        int    l             = 1;
                        while (l <= randAtt)
                        {
                            int randSelection = new Random().Next(9);
                            if (!strAtt.Contains(attendees[randSelection]))
                            {
                                strAtt += attendees[randSelection] + ",";
                            }
                            else
                            {
                                randAtt++;
                            }
                            l++;
                        }
                        strAtt        = strAtt.Remove(strAtt.Length - 1, 1);
                        app.Attendees = strAtt;
                        int orgId = new Random().Next(9);
                        app.Organizer = attendees[orgId];
                        int subjId = new Random().Next(7);
                        app.Subject = subject[subjId] + " with " + app.Organizer;

                        int day = new Random().Next(1, 28);
                        app.StartDate = new DateTime(2018, i, day, new Random().Next(7, 20), new Random().Next(59), 0);
                        app.EndDate   = app.StartDate.Value.AddHours(1);
                        this.entities.Appointment.Add(app);
                        this.entities.SaveChanges();
                    }
                }
                return(Ok());
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.InnerException.Message));
            }
        }
Example #2
0
 /// <summary>
 /// Get Service information based on appointmentId
 /// </summary>
 /// <param name="a"></param>
 /// <returns></returns>
 private static Models.ServiceModel GetServiceInformation(Data.Appointment a)
 {
     try
     {
         string CustomFieldObjectName = string.Empty;
         if (a.ServiceId != null)
         {
             return(new Models.ServiceModel()
             {
                 ServiceId = a.Service.ServiceId,
                 CreatedBy = a.Service.CreatedBy,
                 CreatedDate = a.Service.CreatedDate,
                 ModifiedBy = a.Service.ModifiedBy,
                 ModifiedDate = a.Service.ModifiedDate,
                 ClientId = a.Service.ClientId,
                 ProcedureCodeId = a.Service.ProcedureCodeId,
                 DateOfService = a.Service.DateOfService,
                 EndDateOfService = a.Service.EndDateOfService,
                 Unit = a.Service.Unit,
                 UnitType = a.Service.UnitType,
                 Status = a.Service.Status,
                 ClinicianId = a.Service.ClinicianId,
                 ClinicianName = DataService.GetClinicianName((int)a.Service.ClinicianId),
                 AttendingId = a.Service.AttendingId,
                 ProgramId = a.Service.ProgramId,
                 LocationId = a.Service.LocationId,
                 Billable = a.Service.Billable,
                 SpecificLocation = a.Service.SpecificLocation,
                 DateTimeIn = a.Service.DateTimeIn,
                 DateTimeOut = a.Service.DateTimeOut,
                 Diagnosis = AppointmentRepository.GetDiagnosis(a.Service),
                 CustomFields = AppointmentRepository.GetCustomFields(a.Service, ref CustomFieldObjectName),
                 CustomFieldObjectName = CustomFieldObjectName,
                 Document = AppointmentRepository.CreateModelDocument(a.Service.Documents.FirstOrDefault()),
                 ProcedureCodeName = AppointmentRepository.GetProcedureCodeName(a.Service.ProcedureCodeId),
                 LocationName = AppointmentRepository.GetLocationName(a.Service.LocationId),
                 ProgramName = AppointmentRepository.GetProgramName(a.Service.ProgramId)
             });
         }
         else
         {
             return(null);
         }
     }
     catch (Exception ex)
     {
         Exception excep = new Exception("Exception occured in BriefcaseRepositiry.GetServiceInformation method." + ex.Message);
         throw excep;
     }
 }
        private static Models.Appointment MapToDto(Data.Appointment dbo)
        {
            var dto = new Models.Appointment
            {
                Date     = dbo.Date,
                CreateOn = dbo.CreateOn,
                Id       = dbo.ExternalId
            };

            if (dbo.Participants != null)
            {
                dto.Participant = dbo.Participants.Where(x => !x.DeletedAt.HasValue).Select(x => x.Name).ToArray();
            }

            dto.Type = dbo.Type.ToString();
            return(dto);
        }
Example #4
0
        public List <MindBodyDemo.Models.Data.Appointment> GetStaffAppointments(string first, string lastName, string staffId)
        {
            GetStaffAppointmentsRequest request = new GetStaffAppointmentsRequest();

            // for source credentials
            AppointmentService.SourceCredentials sourceCredentials = new AppointmentService.SourceCredentials();
            sourceCredentials.SourceName = "MBO.Hsiang-Ting.Yang";
            sourceCredentials.Password   = "******";
            int[] ids = new int[1];
            ids[0] = -31100;
            sourceCredentials.SiteIDs = ids;

            request.SourceCredentials = sourceCredentials;

            // for user credentials
            AppointmentService.StaffCredentials staffCredentials = new AppointmentService.StaffCredentials();
            staffCredentials.Username = first + "." + lastName;
            staffCredentials.Password = first[0].ToString().ToLower() + lastName[0].ToString().ToLower() + staffId;
            staffCredentials.SiteIDs  = ids;

            request.StaffCredentials = staffCredentials;
            request.StartDate        = new DateTime(2014, 1, 3);
            request.EndDate          = new DateTime(2014, 1, 4);

            MindBodyDemo.AppointmentService.AppointmentService appointmentServ = new AppointmentService.AppointmentService();
            var result = appointmentServ.GetStaffAppointments(request);

            List <MindBodyDemo.Models.Data.Appointment> apps = new List <MindBodyDemo.Models.Data.Appointment>();

            if (result != null && result.Appointments != null)
            {
                foreach (var app in result.Appointments)
                {
                    MindBodyDemo.Models.Data.Appointment data = new Data.Appointment();
                    data.appointmentDate = app.StartDateTime.Value.ToString("yyyy-MM-dd");
                    data.startDate       = app.StartDateTime.Value.TimeOfDay.ToString();
                    data.endDate         = app.EndDateTime.Value.TimeOfDay.ToString();
                    data.appointmentType = app.SessionType.Name;

                    data.clientName = app.Client.FirstName + app.Client.LastName;
                    apps.Add(data);
                }
            }

            return(apps);
        }
        public AppointmentModule()
        {
            this.RequiresAuthentication();

            Get("/api/appointment", action: async(args, ct) =>
            {
                var dl  = new Data.DataLayer();
                var dbo = await dl.GetAppointments(Context.CurrentUser.Identity.Name);
                var dto = dbo.Select(MapToDto).ToArray();
                return(Response.AsJson(dto));
            });

            Put("/api/appointment", action: async(args, ct) =>
            {
                var dl  = new Data.DataLayer();
                var dto = this.Bind <Models.Appointment>();

                var dbo = new Data.Appointment
                {
                    ExternalId = Guid.NewGuid(),
                    CreateOn   = DateTime.UtcNow,
                    Type       = Data.AppointmentType.Planning,
                    Date       = dto.Date,
                    UserId     = Context.CurrentUser.Identity.Name
                };
                dbo.Type = Enum.Parse <Data.AppointmentType>(dto.Type);

                await dl.SaveAppointment(dbo);


                return(HttpStatusCode.Created);
            });

            Post("/api/appointment/{id}", action: async(args, ct) =>
            {
                var dl  = new Data.DataLayer();
                var id  = Guid.Parse(args.id);
                var dto = this.Bind <Models.Appointment>();
                Data.Appointment dbo = await dl.GetAppointment(id, Context.CurrentUser.Identity.Name);

                dbo.Date = dto.Date;
                dbo.Type = Enum.Parse <Data.AppointmentType>(dto.Type);

                await dl.SaveAppointment(dbo);

                return(HttpStatusCode.OK);
            });


            Put("/api/appointment/{id}/participant/{name}", action: async(args, ct) =>
            {
                var id   = Guid.Parse(args.id);
                var name = args.name;

                var dl = new Data.DataLayer();
                Data.Appointment dbo = await dl.GetAppointment(id, Context.CurrentUser.Identity.Name);
                if (dbo.Participants == null)
                {
                    dbo.Participants = new List <Data.Participant>();
                }
                var participant = dbo.Participants.FirstOrDefault(x => x.Name == name);
                if (participant == null)
                {
                    participant = new Data.Participant
                    {
                        Name      = name,
                        CreatedAt = DateTime.UtcNow
                    };
                    dbo.Participants.Add(participant);
                }
                participant.DeletedAt = null;

                await dl.SaveAppointment(dbo);

                return(HttpStatusCode.Created);
            });

            Delete("/api/appointment/{id}/participant/{name}", action: async(args, ct) =>
            {
                var dl = new Data.DataLayer();

                var id   = Guid.Parse(args.id);
                var name = args.name;

                Data.Appointment dbo = await dl.GetAppointment(id, Context.CurrentUser.Identity.Name);
                if (dbo.Participants == null)
                {
                    dbo.Participants = new List <Data.Participant>();
                }
                var participant = dbo.Participants.FirstOrDefault(x => x.Name == name);
                if (participant != null)
                {
                    participant.DeletedAt = DateTime.UtcNow;
                }
                await dl.SaveAppointment(dbo);
                return(HttpStatusCode.OK);
            });
        }
Example #6
0
 public Appointment(Data.Appointment appointment)
 {
     Id     = appointment.Id;
     TaskId = appointment.TaskId;
 }