public void MarkAsSeen(int appointmentRequestId)
        {
            AppointmentRequest appointmentRequest = GetAppointmentRequest(appointmentRequestId);

            appointmentRequest.SeenByStaff = true;
            _dataContext.Save();
        }
Exemple #2
0
        private async Task CheckSingleAppointment(double?latitude, double?longitude, DateTime startDate, string zipCode, string locationText)
        {
            AppointmentResponse result = new AppointmentResponse()
            {
                success = false
            };

            try
            {
                var appointmentRequest = new AppointmentRequest();

                appointmentRequest.Build("99", zipCode, startDate.ToString("yyyy-MM-dd"), 25);

                result = await _appointmentChecker.CheckForAppointmentAsync(appointmentRequest.ToString());

                result           = AddLatLongIfAvailable(result, latitude, longitude);
                result.stateName = locationText;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            if (result.success == false || result.appointmentsAvailable == false)
            {
                _failedChecks.Add(result);
                Console.Write(".");
            }
            else
            {
                _successfulChecks.Add(result);
                Console.Write($"«{result.zipCode}/{result.stateCode}»");
            }
        }
        public async Task <AppointmentRequest> CreateAppointmentRequest(DateTime start, DateTime end, Patient patient, Doctor requester, Doctor proposedDoctor, DateTime timestamp, Room room)
        {
            var appointmentRequest = new AppointmentRequest();

            await using var context = ContextFactory.CreateDbContext();
            var createdAppointmentRequest = (await context.AppointmentRequests.AddAsync(appointmentRequest)).Entity;
            await context.SaveChangesAsync();

            createdAppointmentRequest.IsActive       = true;
            createdAppointmentRequest.Room           = room;
            createdAppointmentRequest.StartDate      = start;
            createdAppointmentRequest.EndDate        = end;
            createdAppointmentRequest.IsApproved     = false;
            createdAppointmentRequest.Patient        = patient;
            createdAppointmentRequest.Requester      = requester;
            createdAppointmentRequest.ProposedDoctor = proposedDoctor;

            await using var context1 = ContextFactory.CreateDbContext();
            context.AppointmentRequests.Update(appointmentRequest);
            await context.SaveChangesAsync();

            await _notificationService.PublishAppointmentRequestNotification(appointmentRequest, timestamp, string.Empty);

            return(createdAppointmentRequest);
        }
Exemple #4
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            int type = Convert.ToInt32((Request.Form["ServiceType"]));

            var newAppointmentRequest = new AppointmentRequest
            {
                AppointmentDate = AppointmentRequest.AppointmentDate,
                AppointmentType = (AppointmentType)type,
                ContactEmail    = AppointmentRequest.ContactEmail,
                ContactPhone    = AppointmentRequest.ContactPhone,
                FirstName       = AppointmentRequest.FirstName,
                LastName        = AppointmentRequest.LastName,
                Location        = AppointmentRequest.Location,
                Message         = AppointmentRequest.Message,
                RequestDateTime = DateTime.Now,
                RequestStatus   = RequestStatus.Requested
            };

            GenerateEmail(newAppointmentRequest);

            _context.AppointmentRequests.Add(newAppointmentRequest);
            await _context.SaveChangesAsync();

            return(RedirectToPage("/Index"));
        }
        public void DeleteRequest(int appointmentRequestId)
        {
            AppointmentRequest appointmentRequest = GetAppointmentRequest(appointmentRequestId);

            _dataContext.AppointmentRequests.Remove(appointmentRequest);
            _dataContext.Save();
        }
Exemple #6
0
        /// <summary>
        /// Create and configure the organization service proxy.
        /// Initiate the method to create any data that this sample requires.
        /// Schedule a resource.
        /// Optionally delete any entity records that were created for this sample.
        /// </summary>
        /// <param name="serverConfig">Contains server connection information.</param>
        /// <param name="promptforDelete">When True, the user will be prompted to delete all
        /// created entities.</param>
        public void Run(ServerConnection.Configuration serverConfig, bool promptForDelete)
        {
            try
            {
                // Connect to the Organization service.
                // The using statement assures that the service proxy will be properly disposed.
                using (_serviceProxy = new OrganizationServiceProxy(serverConfig.OrganizationUri, serverConfig.HomeRealmUri, serverConfig.Credentials, serverConfig.DeviceCredentials))
                {
                    // This statement is required to enable early-bound type support.
                    _serviceProxy.EnableProxyTypes();

                    // Call the method to create any data that this sample requires.
                    CreateRequiredRecords();

                    //<snippetScheduleResource1>
                    // Create the van required resource object.
                    RequiredResource vanReq = new RequiredResource
                    {
                        ResourceId     = _vanId,
                        ResourceSpecId = _specId
                    };

                    // Create the appointment request.
                    AppointmentRequest appointmentReq = new AppointmentRequest
                    {
                        RequiredResources = new RequiredResource[] { vanReq },
                        Direction         = SearchDirection.Backward,
                        Duration          = 60,
                        NumberOfResults   = 10,
                        ServiceId         = _plumberServiceId,
                        // The search window describes the time when the resouce can be scheduled.
                        // It must be set.
                        SearchWindowStart = DateTime.Now.ToUniversalTime(),
                        SearchWindowEnd   = DateTime.Now.AddDays(7).ToUniversalTime(),
                        UserTimeZoneCode  = 1
                    };

                    // Verify whether there are openings available to schedule the appointment using this resource
                    SearchRequest search = new SearchRequest
                    {
                        AppointmentRequest = appointmentReq
                    };
                    SearchResponse searched = (SearchResponse)_serviceProxy.Execute(search);

                    if (searched.SearchResults.Proposals.Length > 0)
                    {
                        Console.WriteLine("Openings are available to schedule the resource.");
                    }
                    //</snippetScheduleResource1>

                    DeleteRequiredRecords(promptForDelete);
                }
            }
            // Catch any service fault exceptions that Microsoft Dynamics CRM throws.
            catch (FaultException <Microsoft.Xrm.Sdk.OrganizationServiceFault> )
            {
                // You can handle an exception here or pass it back to the calling method.
                throw;
            }
        }
        public HttpResponseMessage Post(AppointmentRequest appointment)
        {
            if (appointment == null) {
                return Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Invalid or missing data in body.");
            }

            AppointmentMessage msg;
            try {
                msg = _repository.GetItem(appointment.Identifier);
            } catch (ArgumentException) {
                msg = null;
            }

            if (msg != null) {
                if (msg.State == State.Conflict) {
                    _repository.Replace(appointment.Identifier, appointment);
                }
            } else {
                _repository.Create(appointment);
                msg = _repository.GetItem(appointment.Identifier);
            }

            var resp = new HttpResponseMessage(HttpStatusCode.Created);
            var ub = new UriBuilder(Request.RequestUri);
            ub.Path = ub.Path.TrimEnd('/') + '/' + msg.Appointment.Identifier;

            resp.Headers.Add("Location", ub.Uri.ToString());
            return resp;
        }
        public void WhenAppointmentDateOnMaxDate_AppointmentShouldBeCreatedForThatDate()
        {
            // Values
            DateTime           now   = new DateTime(2018, 5, 15, 11, 42, 32);
            DateTime           today = now.Date;
            int                maxAppointmentDays = 15;
            AppointmentRequest request            = new AppointmentRequest()
            {
                AppointmentDate = new DateTime(2018, 5, 30),
                Hours           = 4
            };

            // Arrange
            var mock = new Mock <AppointmentServicePartialMock>();

            mock.Setup(m => m.Today).Returns(today);
            mock.Setup(m => m.Now).Returns(now);
            mock.Setup(m => m.MaxAppointmentDays).Returns(maxAppointmentDays);
            mock.Setup(m => m.GetConfirmationCode()).Returns("ABCDEFG");

            // Act
            var appt = mock.Object.CreateAppointment(request);

            // Assert
            Assert.NotNull(appt);
            Assert.Equal(new DateTime(2018, 5, 30), appt.AppointmentDate);
            Assert.Equal("ABCDEFG", appt.ConfirmationCode);
            Assert.Equal(now, appt.CreateTime);
        }
        public async Task <IActionResult> Index(AppointmentRequest appointmentRequest)
        {
            //todo validate
            await _appointmentService.SubmitForProcessing(appointmentRequest);

            return(RedirectToAction(nameof(Confirmation)));
        }
Exemple #10
0
        public async Task <Response> Create(AppointmentRequest model)
        {
            Appointment info   = _mapper.Map <Appointment>(model);
            int         result = await _appointmentRepository.Create
                                     (info,
                                     model.IPSId,
                                     model.CustomerId,
                                     model.DoctorId);

            if (result > 0)
            {
                return(new Response
                {
                    IsSuccess = true,
                    Message = Messages.Created.ToString(),
                    Result = result
                });
            }
            else
            {
                return(new Response
                {
                    IsSuccess = false,
                    Message = Messages.NotCreated.ToString()
                });
            }
        }
Exemple #11
0
        public new ActionResult Request(AppointmentRequest model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            Appointment app = new Appointment()
            {
                ID        = model.ID,
                Date      = model.Date,
                DoctorID  = model.DoctorID,
                PatientID = AuthenticationManager.LoggedUser.ID
            };

            AppointmentRepository appRepo = new AppointmentRepository();

            // check if appointment already exists
            Appointment findApp = appRepo.GetFirst(a => (app.Date >= a.Date && app.Date <= DbFunctions.AddMinutes(a.Date, 30)) && app.DoctorID == a.DoctorID);

            if (findApp == null)
            {
                appRepo.Save(app);
            }

            else
            {
                ModelState.AddModelError(string.Empty, "There is already an appointment scheduled for this date and hour!");
                return(View(model));
            }

            return(RedirectToAction("Index"));
        }
        public JsonResult CreateAppointment(string employeeID, string clinicId, string poliId, string doctorId, string necesity, string AppointmentDate, string MCUPackage)
        {
            var response = new AppointmentResponse();
            var _model   = new AppointmentModel
            {
                AppointmentDate = CommonUtils.ConvertStringDate2Datetime(AppointmentDate),
                ClinicID        = Convert.ToInt64(clinicId),
                EmployeeID      = Convert.ToInt64(employeeID),
                DoctorID        = Convert.ToInt64(doctorId),
                PoliID          = Convert.ToInt64(poliId),
                RequirementID   = Convert.ToInt16(necesity),
                MCUPakageID     = Convert.ToInt64(MCUPackage),
            };

            if (Session["UserLogon"] != null)
            {
                _model.Account = (AccountModel)Session["UserLogon"];
            }
            var request = new AppointmentRequest
            {
                Data = _model
            };

            response = new AppointmentValidator(_unitOfWork).Validate(request);

            return(Json(new { Status = response.Status, Message = response.Message }, JsonRequestBehavior.AllowGet));
        }
Exemple #13
0
        public async Task CreateAsync(AppointmentRequest request)
        {
            Appointment appointment = new Appointment((Guid)request.MedicamentId, (Guid)request.PatientId, (Guid)request.DoctorId);

            await applicationContext.Appointments.AddAsync(appointment);

            await applicationContext.SaveChangesAsync();
        }
        public virtual async Task <int> SaveAsync(AppointmentRequest appointmentRequest, CancellationToken cancellationToken)
        {
            var result = await dbContext.AppointmentRequests.AddAsync(appointmentRequest, cancellationToken);

            await dbContext.SaveChangesAsync();

            return(result.Entity.Id);
        }
Exemple #15
0
        public new ActionResult Request()
        {
            AppointmentRequest model = new AppointmentRequest()
            {
                Date = DateTime.Now
            };

            return(View(model));
        }
 public ActionResult Index(AppointmentRequest model)
 {
     if (ModelState.IsValid)
     {
         // here we would save the appointment to a database
         return(View("Confirmation", model));
     }
     else
     {
         return(View("Index", model));
     }
 }
        public ActionResult Index(AppointmentRequest model)
        {
            if (string.IsNullOrEmpty(model.ClientName))
            {
                ModelState.AddModelError("ClientName",
                                         "Please enter your name");
            }

            if (ModelState.IsValidField("Date"))
            {
                if (model.Date < DateTime.Today.AddDays(1))
                {
                    ModelState.AddModelError("Date",
                                             "Appointments cannot be same-day or in the past");
                }
                else if (model.Date.DayOfWeek == DayOfWeek.Saturday ||
                         model.Date.DayOfWeek == DayOfWeek.Sunday)
                {
                    ModelState.AddModelError("Date",
                                             "We do not accept weekend appointments");
                }
            }
            else
            {
                ModelState.AddModelError("Date",
                                         "Please enter a valid date for the appointment");
            }

            if (!model.TermsAccepted)
            {
                ModelState.AddModelError("TermsAccepted",
                                         "You must accept the terms to book an appointment");
            }

            if (ModelState.IsValidField("ClientName") && ModelState.IsValidField("Date"))
            {
                if (model.ClientName == "Garfield" && model.Date.DayOfWeek == DayOfWeek.Monday)
                {
                    ModelState.AddModelError("", "Garfield may not book on Mondays");
                }
            }

            if (ModelState.IsValid)
            {
                // here we would save the appointment to a database
                return(View("Confirmation", model));
            }
            else
            {
                // send them back to the entry form
                return(View("Index", model));
            }
        }
Exemple #18
0
        public async Task <IActionResult> Edit([FromRoute] Guid id, [FromBody] AppointmentRequest request)
        {
            try
            {
                var appointment = await appointmentService.EditAsync(id, request);

                return(Ok(appointment));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
Exemple #19
0
        public async Task <IActionResult> Create([FromBody] AppointmentRequest request)
        {
            try
            {
                await appointmentService.CreateAsync(request);

                return(Ok());
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
        public AppointmentRequest RequestAppointment(int patientId, int?doctorId = null, string reason = null)
        {
            var appointmentRequest = new AppointmentRequest
            {
                DoctorId  = doctorId,
                PatientId = patientId,
                Reason    = reason
            };

            _dataContext.AppointmentRequests.Add(appointmentRequest);
            _dataContext.Save();

            return(appointmentRequest);
        }
Exemple #21
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            AppointmentRequest = await _context.AppointmentRequests.FirstOrDefaultAsync(m => m.Id == id);

            if (AppointmentRequest == null)
            {
                return(NotFound());
            }
            return(Page());
        }
        public async Task <ActionResult> Create([FromBody] AppointmentRequest model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                return(Ok(await _appointmentService.Create(model)));
            }
            catch (Exception)
            {
                return(BadRequest());
            }
        }
Exemple #23
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            AppointmentRequest = await _context.AppointmentRequests.FindAsync(id);

            if (AppointmentRequest != null)
            {
                _context.AppointmentRequests.Remove(AppointmentRequest);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
Exemple #24
0
        public async Task <int> Handle(CreateAppointmentCommand request, CancellationToken cancellationToken)
        {
            var appointmentRequest = new AppointmentRequest()
            {
                Title          = request.Title,
                Description    = request.Description,
                Longitude      = request.Longitude,
                Latitude       = request.Latitude,
                Duration       = request.Duration,
                Date           = request.Date,
                ClientId       = request.ClientId,
                TenantId       = request.TenantId,
                CreatedDateUtc = DateTime.Now
            };

            return(await appointmentRequestRepository.SaveAsync(appointmentRequest, cancellationToken));
        }
        public void Appointment_IsConflicting_730()
        {
            Mock <IRepository <Appointment> > appointmentRepoMock = new Mock <IRepository <Appointment> >();
            Mock <IShop>   shopMock   = new Mock <IShop>();
            Mock <IBarber> barberMock = new Mock <IBarber>();

            barberMock.Setup(b => b.DisplayName)
            .Returns("Barber")
            .Verifiable();

            barberMock.Setup(b => b.Equals(It.Is <IBarber>(o => o.DisplayName == "Barber")))
            .Returns(true)
            .Verifiable();

            var now = new DateTime(2018, 1, 1, 7, 30, 0);
            AppointmentRequest initialRequest = new AppointmentRequest(shopMock.Object)
            {
                StartDateTime   = now,
                RequestedBarber = barberMock.Object,
                Service         = new BarberService()
                {
                    DisplayName = "Some Service", Duration = TimeSpan.FromMinutes(40)
                }
            };
            Appointment appointment = new Appointment(appointmentRepoMock.Object);

            appointment.CopyFrom(initialRequest);

            Appointment        conflictingAppt    = new Appointment(appointmentRepoMock.Object);
            AppointmentRequest conflictingRequest = new AppointmentRequest(shopMock.Object)
            {
                StartDateTime   = now.AddMinutes(-15),
                RequestedBarber = barberMock.Object,
                Service         = new BarberService()
                {
                    DisplayName = "Some Service", Duration = TimeSpan.FromMinutes(40)
                }
            };

            conflictingAppt.CopyFrom(conflictingRequest);

            bool result = appointment.IsConflicting(conflictingAppt);

            Assert.True(result);
            barberMock.VerifyAll();
        }
        public void Appointment_IsConflicting(int serviceMinuteLength, int conflictingMinuteStartTimeAddition, bool expectedConflict)
        {
            Mock <IRepository <Appointment> > appointmentRepoMock = new Mock <IRepository <Appointment> >();
            Mock <IShop>   shopMock   = new Mock <IShop>();
            Mock <IBarber> barberMock = new Mock <IBarber>();

            barberMock.Setup(b => b.DisplayName)
            .Returns("Barber")
            .Verifiable();

            barberMock.Setup(b => b.Equals(It.Is <IBarber>(o => o.DisplayName == "Barber")))
            .Returns(true)
            .Verifiable();

            var now = DateTime.Now;
            AppointmentRequest initialRequest = new AppointmentRequest(shopMock.Object)
            {
                StartDateTime   = now,
                RequestedBarber = barberMock.Object,
                Service         = new BarberService()
                {
                    DisplayName = "Some Service", Duration = TimeSpan.FromMinutes(30)
                }
            };
            Appointment appointment = new Appointment(appointmentRepoMock.Object);

            appointment.CopyFrom(initialRequest);

            Appointment        conflictingAppt    = new Appointment(appointmentRepoMock.Object);
            AppointmentRequest conflictingRequest = new AppointmentRequest(shopMock.Object)
            {
                StartDateTime   = now.AddMinutes(conflictingMinuteStartTimeAddition),
                RequestedBarber = barberMock.Object,
                Service         = new BarberService()
                {
                    DisplayName = "Some Service", Duration = TimeSpan.FromMinutes(serviceMinuteLength)
                }
            };

            conflictingAppt.CopyFrom(conflictingRequest);

            bool result = appointment.IsConflicting(conflictingAppt);

            Assert.Equal(expectedConflict, result);
            barberMock.VerifyAll();
        }
Exemple #27
0
        protected void appRequest_Click(object sender, EventArgs e)
        {
            midLineDBEntities  db          = new midLineDBEntities();
            AppointmentRequest appointment = new AppointmentRequest
            {
                DoctorID  = doctorID,
                PatientID = PatientID,
                Time      = txtDate.Text + "  " + TimeSelector1.Hour.ToString() + ":" + TimeSelector1.Minute.ToString() + " " + TimeSelector1.AmPm.ToString()
            };

            if (appointment != null)
            {
                db.AppointmentRequests.Add(appointment);
                db.SaveChanges();
                successAlert.Attributes.Remove("hidden");
            }
        }
Exemple #28
0
        public async Task <Appointment> EditAsync(Guid id, AppointmentRequest request)
        {
            Appointment newAppointment = new Appointment((Guid)request.MedicamentId, (Guid)request.PatientId, (Guid)request.DoctorId);
            Appointment appointment    = await GetAsync(id);

            if (appointment == null)
            {
                throw new Exception(localizer["Appointment with this identifier doesn`t exist."]);
            }

            appointment    = newAppointment;
            appointment.Id = id;

            applicationContext.Appointments.Update(appointment);
            await applicationContext.SaveChangesAsync();

            return(await GetAsync(appointment.Id));
        }
Exemple #29
0
        public AppointmentResponse GetDoctorBasedOnPoli(AppointmentRequest request)
        {
            var response = new AppointmentResponse();
            List <PoliScheduleModel> availableSchedules = new List <PoliScheduleModel>();
            // DateTime start=new DateTime(request.Data.AppointmentDate.Year, request.Data.AppointmentDate.Month, request.Data.AppointmentDate.Day, )
            var qry = _unitOfWork.PoliScheduleRepository.Get(x => x.PoliID == request.Data.PoliID && (DbFunctions.TruncateTime(x.StartDate) <= request.Data.AppointmentDate && DbFunctions.TruncateTime(x.EndDate) >= request.Data.AppointmentDate));

            foreach (var item in qry)
            {
                availableSchedules.Add(Mapper.Map <PoliSchedule, PoliScheduleModel>(item));
            }

            var data = availableSchedules.Skip(request.Skip).Take(request.PageSize).ToList();

            response.schedules       = data;
            response.RecordsTotal    = availableSchedules.Count;
            response.RecordsFiltered = availableSchedules.Count;
            return(response);
        }
        public override bool IsValid(object value)
        {
            if (value is AppointmentRequest)
            {
                AppointmentRequest model = (AppointmentRequest)value;

                if (!string.IsNullOrEmpty(model.ClientName) && model.ClientName == "Garfield")
                {
                    if (model.Date.DayOfWeek == DayOfWeek.Monday)
                    {
                        return(false);
                    }

                    return(true);
                }
            }

            return(false);
        }
        public PreBooking(AppointmentRequest appointmentargs)
        {
            InitializeComponent();

            float.TryParse(appointmentargs.Service.Price, out price);
            ServiceDescription.Text = appointmentargs.Service.ServiceName;

            if (PlacesModel.PlacesList.Count != 0)
            {
                SelectedLocation.Text = appointmentargs.Place.PlaceDetail;
            }
            else
            {
                SelectedLocation.Text = "No places available";
            }


            SelectedPayment.Text  = appointmentargs.Payment.PaymentDetail;
            SelectedTime.Text     = "Pick a time";
            SelectedDate.Text     = "Pick a date";
            AreaStepper.IsVisible = false;
            HousekeeperCount.Text = appointmentargs.Housekeepers.ToString();
            Sub.IsEnabled         = false;
            Sub.BorderColor       = SubSymbol.TextColor = Color.LightGray;
            Add.IsEnabled         = true;

            InvisibleDatePicker.SetValue(DatePicker.MinimumDateProperty, System.DateTime.Today.AddDays(7));
            InvisibleDatePicker.SetValue(DatePicker.MaximumDateProperty, System.DateTime.Today.AddDays(7).AddMonths(3));
            appointmentRequest = appointmentargs;

            if (appointmentRequest.Service.ServiceName.Contains("Commercial"))
            {
                appointmentRequest.Area      = 50;
                AreaCount.Text               = appointmentRequest.Area.ToString();
                HousekeeperStepper.IsVisible = false;
                AreaStepper.IsVisible        = true;
                appointmentRequest.Area      = 50;
                SubArea.BorderColor          = SubSymbolArea.TextColor = Color.LightGray;
            }
            ServicePrice.Text = this.SubDetails;
            Title             = "Set your booking details";
        }
    public AppointmentResponse GetDocSchedule(AppointmentRequest request)
    {
        AppointmentResponse response = new AppointmentResponse();

        // Set correlation Id
        response.CorrelationId = request.RequestId;

        try
        {

            // Get customer list via Customer Facade.
            AppointmentFacade facade = new AppointmentFacade();
            response.ds= facade.GetDocSchedule(request.date,request.docID);

        }
        catch (Exception ex)
        {
            response.Acknowledge = AcknowledgeType.Failure;
            response.Message = "Request cannot be handled at this time."+ex.Message;
        }

        return response;
    }
Exemple #33
0
        public HttpResponseMessage GetTestData(bool debug)
        {
            if (debug) {
                var appointment = new AppointmentRequest {
                    Description  = "This is a description",
                    Location     = "Location: Somewhere in the universe",
                    Participants = new List<Participant> {
                        new Participant { Name = "Pelle", Username = "******" },
                        new Participant { Name = "Kalle", Username = "******" }
                    },
                    Priority   = 10,
                    Sender     = Sender.Studies,
                    StartTime  = DateTime.Now,
                    User       = "******",
                    Identifier = Guid.NewGuid().ToString("N"),
                    Type       = AppointmentType.SelfStudies
                };

                return Request.CreateResponse(HttpStatusCode.OK, appointment);
            }

            return Request.CreateResponse(HttpStatusCode.OK, GetAll());
        }
Exemple #34
0
        /// <summary>
        /// Create and configure the organization service proxy.
        /// Initiate the method to create any data that this sample requires.
        /// Schedule a resource.        
        /// Optionally delete any entity records that were created for this sample.
        /// </summary>
        /// <param name="serverConfig">Contains server connection information.</param>
        /// <param name="promptforDelete">When True, the user will be prompted to delete all
        /// created entities.</param>
        public void Run(ServerConnection.Configuration serverConfig, bool promptForDelete)
        {
            try
            {

                // Connect to the Organization service. 
                // The using statement assures that the service proxy will be properly disposed.
                using (_serviceProxy = new OrganizationServiceProxy(serverConfig.OrganizationUri, serverConfig.HomeRealmUri,serverConfig.Credentials, serverConfig.DeviceCredentials))
                {
                    // This statement is required to enable early-bound type support.
                    _serviceProxy.EnableProxyTypes();

                    // Call the method to create any data that this sample requires.
                    CreateRequiredRecords();

                    //<snippetScheduleResource1>
                    // Create the van required resource object.
                    RequiredResource vanReq = new RequiredResource
                    {
                        ResourceId = _vanId,
                        ResourceSpecId = _specId
                    };

                    // Create the appointment request.
                    AppointmentRequest appointmentReq = new AppointmentRequest
                    {
                        RequiredResources = new RequiredResource[] { vanReq },
                        Direction = SearchDirection.Backward,
                        Duration = 60,
                        NumberOfResults = 10,
                        ServiceId = _plumberServiceId,
                        // The search window describes the time when the resouce can be scheduled.
                        // It must be set.
                        SearchWindowStart = DateTime.Now.ToUniversalTime(),
                        SearchWindowEnd = DateTime.Now.AddDays(7).ToUniversalTime(),
                        UserTimeZoneCode = 1
                    };

                    // Verify whether there are openings available to schedule the appointment using this resource              
                    SearchRequest search = new SearchRequest
                    {
                        AppointmentRequest = appointmentReq
                    };
                    SearchResponse searched = (SearchResponse)_serviceProxy.Execute(search);

                    if (searched.SearchResults.Proposals.Length > 0)
                    {
                        Console.WriteLine("Openings are available to schedule the resource.");
                    }
                    //</snippetScheduleResource1>

                    DeleteRequiredRecords(promptForDelete);
                }
            }
            // Catch any service fault exceptions that Microsoft Dynamics CRM throws.
            catch (FaultException<Microsoft.Xrm.Sdk.OrganizationServiceFault>)
            {
                // You can handle an exception here or pass it back to the calling method.
                throw;
            }
        }
    /// <summary>
    /// Gets an instructors schedule
    /// </summary>
    /// <param name="strInsID">A string value with a numeric integer representing 
    /// an instructor.</param>
    /// <remarks>
    /// Pseudocode follows below
    /// <code>
    /// Begin
    ///    Get Day_ID for selected date and instructor
    ///    Get Schedule for selected Day_ID    
    /// End
    /// </code>
    /// </remarks>
    private void GetDocSchedule(string strDocID)
    {
        try
        {
            proxy = new WebRef.Service();

            // Proxy must accept and hold cookies
            //   proxy.CookieContainer = new System.Net.CookieContainer();
            proxy.Url = new Uri(proxy.Url).AbsoluteUri;
            AppointmentRequest aRequest = new AppointmentRequest();
            AppointmentTransferObject aTransferObject = new AppointmentTransferObject();
            aTransferObject.date = Convert.ToDateTime(txtDate.Text);
            aTransferObject.doctorID = Convert.ToInt32(strDocID);
            aRequest.date = aTransferObject.date;
            aRequest.docID = aTransferObject.doctorID;

            AppointmentResponse aResponse = proxy.GetDocSchedule(aRequest);

            dsDay = aResponse.ds.Tables[0];
            dsSchedule = aResponse.ds.Tables[1];

            Session["dsSchedule"] = dsSchedule;

            //  lblDay.Text = dsDay.Rows[0][1].ToString();

            // Get schedule

        }
        catch (Exception ex)
        {
            lblMessage.ForeColor = Color.Black;
            lblMessage.BackColor = Color.Red;
            lblMessage.Text = ex.ToString();
        }
    }