We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Search for Appointments using WebAPI (Outside the Schedule Control)

Goodday,

I want to be able to search for appointment outside the Schedule Control, directly from my Db Storage. The Schedule control has the ability to 
interpret re-occurrence rule and evaluate time-zones. I need an algorithm to calculate re-occurrence rule and workout the time-zones issues and get the same result as the schedule control agenda and  the "searchAppointment" javascript function.

In summary, its like I need the agenda and search module of the Schedule control outside the Schedule control. I want to be able to search for appointments via WebAPI and get the search result back in json.

Thanks in anticipation of your quick response.

3 Replies

KK Karthigeyan Krishnamurthi Syncfusion Team July 21, 2017 10:46 AM UTC

Hi Charles, 
 
Thank you for contacting Syncfusion support. 
 
To render the appointment as same as the time given in data base (with out considering timezone difference) set ApplyTimeOffset to false with in AppointmentSettings. We are not clear about your other requirements, kindly share the below informations with us to proceed further. 
 
  1. Need agenda and search module of the Schedule control – Are you looking for the searchAppointment source code example? And can you please more specific about the phrase “Agenda of the Schedule control”.
  2. Need an algorithm to calculate re-occurrence rule and to search for appointment outside the Schedule Control – Kindly share more information which clearly depicts these requirements.

Regards, 
Karthigeyan 



CH Charles July 21, 2017 02:41 PM UTC

Goodday,

Let me explain with scenarios

For example I have an webapi link like this http://localhost:9090/Route/searchAppointments?startdate=2017-07-08&enddate=2017-07-20&subject="Charles"

In my controller

public JsonResult SearchAppointments(ScheduleDataSearchQuery search)

        {

            var data = _routeService.GetAllScheduledRoutes(search).Entity;

            return Json(data, JsonRequestBehavior.AllowGet);

        }

In my Service I have below

 public OperationResult<IList<ScheduleData>> GetAllScheduledRoutes(ScheduleDataSearchQuery searchQuery)

        {

            var queryOver = _session.Query<ScheduleData>();

            //switch (searchQuery.Status)

            //{

            //    case EntityStatus.Active:

            //        queryOver = queryOver.Where(item => item.IsActive == true);

            //        break;

            //    case EntityStatus.InActive:

            //        queryOver = queryOver.Where(item => item.IsActive == false);

            //        break;

            //    case EntityStatus.Pending:

            //        queryOver = queryOver.Where(item => item.IsActive == null);

            //        break;

            //    case EntityStatus.Any:

            //        break;

            //}

            if (!string.IsNullOrWhiteSpace(searchQuery.CompanyName))

            {

                if (searchQuery.CompanyName != "All")

                {

                    queryOver =

                        queryOver.Where(item => item.Route.Company.Name.Contains(searchQuery.CompanyName) || item.Route.Company.NameAbbreviation.Contains(searchQuery.CompanyName));

                }

            }

            

          

            if (!string.IsNullOrWhiteSpace(searchQuery.RouteName))

            {

                if (searchQuery.RouteName != "All")

                {

                   

                        queryOver =

                       queryOver.Where(item => item.Route.Name.Contains(searchQuery.RouteName) );


                }

            }


            if (!string.IsNullOrWhiteSpace(searchQuery.Territory))

                queryOver = queryOver.Where(item => item.Route.Origin.TerminalRef.Contains(searchQuery.Territory) || item.Route.Origin.City.Contains(searchQuery.Territory)

                || item.Route.Origin.Location.Contains(searchQuery.Territory) || item.Route.Origin.Country.Name.Contains(searchQuery.Territory) || item.Route.Origin.Country.Capital.Contains(searchQuery.Territory) ||

                item.Route.Destination.TerminalRef.Contains(searchQuery.Territory) || item.Route.Destination.City.Contains(searchQuery.Territory)

                || item.Route.Destination.Location.Contains(searchQuery.Territory) || item.Route.Destination.Country.Name.Contains(searchQuery.Territory) || item.Route.Destination.Country.Capital.Contains(searchQuery.Territory));


            if (searchQuery.CompanyId.HasValue)

                if (searchQuery.CompanyId != 0)

                    queryOver = queryOver.Where(item => item.Route.Company.Id == searchQuery.CompanyId);


            if (searchQuery.RouteId.HasValue)

                if (searchQuery.RouteId != 0)

                    queryOver = queryOver.Where(item => item.Route.Id == searchQuery.RouteId);


            if (searchQuery.Id.HasValue)

                queryOver = queryOver.Where(item => item.Id == searchQuery.Id);


            if (searchQuery.StartDate.HasValue && searchQuery.EndDate.HasValue)

            {

                queryOver = queryOver.Where(item => item.StartTime >= searchQuery.StartDate.Value && item.EndTime <= searchQuery.EndDate.Value);

            }


            if (queryOver.Any())

            {

                return new OperationResult<IList<ScheduleData>>(true) { Entity = queryOver.ToList() };

            }

            return new OperationResult<IList<ScheduleData>>(false, new Exception("Empty Schedule Route List, Please Schedule a Route")) { Entity = new List<ScheduleData>() };

        }


If you look at the code above, you can see that I can search for Appointments (i.e ScheduleData) from my Db but if an appointment has re-occurrence, I want to be able to interpret the re-occurrence e.g

 foreach (var item in queryOver)

            {

                if (item.Recurrence)

                {

                    ---- Interpret and add the re-occurrence dates as individual appointment.

                         

                }

            }

I hope this is more informative.

Also, I want to have a table that will store appointment re-occurrence date series for easy search. In order for me to to this I need to interpret recurrence, recurrence rule and recurrence options.



SE Sellakumar Syncfusion Team July 24, 2017 01:04 PM UTC

Hi Charles,  
 
Thanks for your update. 
 
In Controller side, we can easily find the re-occurrence appointment object based on the below condition: 
 
If (item.Recurrence && item.RecurrenceRule.indexOf(“RECUREDITID”) != -1) 
 
For more details, kindly refer the below KB link: 
 
Kindly check and revert us, if you need any further assistance on this. 
 
Regards, 
Sellakumar K

Loader.
Up arrow icon