private CalendarResponse FilterResults(CalendarResponse response, CalendarRequest request) { IEnumerable <Center> filteredCenters = response.centers; foreach (var center in filteredCenters) { center.sessions = center.sessions.Where(session => session.available_capacity > 0); if (request.min_age_limit != 0) { center.sessions = center.sessions.Where(session => session.min_age_limit <= request.min_age_limit); } if (!string.IsNullOrEmpty(request.vaccine)) { center.sessions = center.sessions.Where(session => session.vaccine == request.vaccine); } } filteredCenters = filteredCenters.Where(center => center.sessions.Any()); if (!string.IsNullOrEmpty(request.fee_type)) { filteredCenters = filteredCenters.Where(center => center.fee_type == request.fee_type); } return(new CalendarResponse { centers = filteredCenters }); }
/* * "embed": { * "leaveType": "VACATION", * "vacationId": "", * "timezone": "Europe/Copenhagen" * }, * * "embed": { * "leaveType": "SICK", * "vacationId": "", * "timezone": "Europe/Copenhagen" * }, * "embed": { * "type": "CHECK_IN", * "timezone": "Europe/Copenhagen", * "canEdit": false * }, * "behaviors": [] * "embed": { * "type": "CHECK_OUT", * "timezone": "Europe/Copenhagen", * "canEdit": false * }, */ private Calendar MapFamlyCalToCalendar(CalendarResponse res, TimeSpan?alarm) { Calendar calendar = new Calendar { ProductIdentifier = "-//Microservice.dk//FamlyCal//DA", }; string[] ignoreTypes = new[] { "CHECK_IN", "CHECK_OUT" }; string[] ignoreLeaveTypes = new[] { "VACATION", "SICK" }; string[] ignoreOriginators = new[] { "Famly.Daycare:ChildCheckin" }; foreach (var period in res.Periodes) { foreach (var day in period.Days) { foreach (var ev in day.Events.Where(e => !ignoreTypes.Contains(e.Descriptor.Type) && !ignoreLeaveTypes.Contains(e.Descriptor.LeaveType) && !ignoreOriginators.Contains(e.Originator.Type))) { calendar.Events.Add(new Model.Event { Summary = ev.Title, Description = ev.SubTitle, Start = ev.From ?? day.Date, End = ev.To ?? day.Date, Alarm = alarm }); } } } return(calendar); }
public async Task <IActionResult> Index() { CalendarResponse response = new CalendarResponse(); response.LastUpdated = (await _context.UpdateTables.SingleAsync(u => u.Key.Equals(UpdateType.Calendar))).LastUpdated; response.Calendars = await _context.CalendarItems.Include(c => c.Calendar).OrderBy(c => c.Start).Select(c => _mapper.Map <CalendarItemDto>(c)).ToListAsync(); return(Ok(response)); }
public async Task <CalendarResponse> PostAsync(CalendarRequest request) { CalendarResponse apiResponse = await apiHandler.CalendarDistrictSearchAsync(request.state_name, request.district_name, request.date); CalendarResponse filtered = FilterResults(apiResponse, request); CalendarResponse sorted = SortResults(filtered); return(sorted); }
public async Task <ActionResult <CalendarResponse> > GetCalendarLink(CalendarRequest calendarRequest) { CalendarDto calendarDto = _mapper.Map <CalendarDto>(calendarRequest); string link = await _calendarService.GetGoogleCalendarLinkAsync(calendarDto); var response = new CalendarResponse { Link = link }; return(Ok(response)); }
public async Task <CalendarResponse> GetCalendarData() { NotifyFunctionCalled(); await Task.Delay(2000); var result = new CalendarResponse(); result.Enabled = true; result.CalState = 0b1011; result.ActiveDays = 0b1001101; result.Date = DateTime.UtcNow; return(result); }
public async Task <CalendarResponse> CalendarDistrictSearchAsync(string stateName, string districtName, string date) { int stateId = States[stateName]; if (!Districts.ContainsKey(stateId)) { GetDistricts(stateId); } int districtId = Districts[stateId][districtName]; var calendarByDistrictUrl = ApiHost + CalendarByDistrictRoute; var parameters = new Dictionary <string, string>(LanguageParam); parameters.Add("district_id", districtId.ToString()); parameters.Add("date", date); CalendarResponse calendarResponse = await HttpGetAsync <CalendarResponse>(calendarByDistrictUrl, parameters); return(calendarResponse); }
public HttpResponseMessage getcalendar(string securityToken, int schoolId) { CalendarResponse response = null; if (IsValid(securityToken)) { ISchool school = new SchoolService(this._dbContext); response = new CalendarResponse { Status = "OK" }; response.eventlist = school.GetCalendarEvents(schoolId); CurrentLoggerProvider.Info(string.Format("Retrieved eventlist. Count = {0}", response.eventlist != null ? response.eventlist.Count() : 0)); } else { response = new CalendarResponse { Status = "Error", ErrorCode = "ERR1001", ErrorMessage = "Invalid or expired token" }; CurrentLoggerProvider.Info(string.Format("Invalid Request. School Id: {0}", schoolId)); } return(Request.CreateResponse(HttpStatusCode.OK, response)); }
public void Tasks_TasksCalendar_Tests() { try { storageService.File.CopyFile(Utils.CloudStorage_Input_Folder + "/sample-mpp.mpp", Utils.CloudStorage_Output_Folder + "/sample-mpp.mpp"); CalendarsResponse calendarsResponse = tasksService.TasksCalendar.ReadProjectCalendarItems("sample-mpp.mpp", Utils.CloudStorage_Output_Folder); CalendarResponse calendarResponse = tasksService.TasksCalendar.GetProjectCalendar("sample-mpp.mpp", 1, Utils.CloudStorage_Output_Folder); calendarResponse.Calendar.Name = "Aspose Calendar"; CalendarItemResponse CalendarItemResponse = tasksService.TasksCalendar.AddNewCalendarToProjectFile("sample-mpp.mpp", string.Empty, Utils.CloudStorage_Output_Folder, calendarResponse.Calendar); tasksService.TasksCalendar.DeleteProjectCalendar("sample-mpp.mpp", 5, string.Empty, Utils.CloudStorage_Output_Folder); CalendarExceptionsResponse calendarExceptionsResponse = tasksService.TasksCalendar.GetListOfCalendarExceptions("sample-mpp.mpp", 1, Utils.CloudStorage_Output_Folder); calendarExceptionsResponse.CalendarExceptions[0].Month = 9; tasksService.TasksCalendar.AddNewCalendarExceptionToACalendar("sample-mpp.mpp", 1, string.Empty, Utils.CloudStorage_Output_Folder, calendarExceptionsResponse.CalendarExceptions[0]); tasksService.TasksCalendar.UpdatesCalendarException("sample-mpp.mpp", 1, 1, string.Empty, Utils.CloudStorage_Output_Folder, calendarExceptionsResponse.CalendarExceptions[0]); tasksService.TasksCalendar.DeletesCalendarException("sample-mpp.mpp", 1, 1, string.Empty, Utils.CloudStorage_Output_Folder); } catch (Exception ex) { Assert.Fail(ex.Message); } }
public CalendarResponse GetGoogleCalendarWithAPI(CalendarRequest request) { /* * string jsonPath = HostingEnvironment.MapPath("~/App_Data/google_calendar_client_secret.json"); * string[] Scopes = {"openid", "email", CalendarService.Scope.CalendarReadonly }; * ClientSecrets secret; * * using (var stream = new FileStream(jsonPath, FileMode.Open, FileAccess.Read)) * { * secret = GoogleClientSecrets.Load(stream).Secrets; * } * * var initializer = new GoogleAuthorizationCodeFlow.Initializer * { * ClientSecrets = new ClientSecrets * { * ClientId = secret.ClientId, * ClientSecret = secret.ClientSecret, * }, * Scopes = Scopes, * }; * * * var flow = new GoogleAuthorizationCodeFlow(initializer); * var identity = await HttpContext.Current.GetOwinContext().Authentication.GetExternalIdentityAsync(DefaultAuthenticationTypes.ApplicationCookie); * var userId = identity.FindFirstValue("GoogleUserId"); */ try { string jsonPath = HostingEnvironment.MapPath("~/App_Data/google_calendar_client_secret.json"); string[] Scopes = { CalendarService.Scope.CalendarReadonly }; GoogleCredential credential; using (var stream = new FileStream(jsonPath, FileMode.Open, FileAccess.Read)) { credential = GoogleCredential.FromStream(stream).CreateScoped(CalendarService.Scope.CalendarReadonly); } var service = new CalendarService(new BaseClientService.Initializer { HttpClientInitializer = credential, ApplicationName = "Test Calendar", ApiKey = ConfigurationManager.AppSettings["GoogleServiceAccountAPIKey"], }); /* * CalendarListResource.ListRequest request0 = service.CalendarList.List(); * request0.MaxResults = 10; * * // List events. * CalendarList calendars = request0.Execute(); * * if (calendars.Items != null && calendars.Items.Count > 0) * { * foreach (var calendarItem in calendars.Items) * { * string desc = calendarItem.Description; * } * } */ EventsResource.ListRequest request1 = service.Events.List(request.CalendarName); request1.TimeMin = request.StartTime; request1.ShowDeleted = false; request1.SingleEvents = true; request1.MaxResults = 10; request1.OrderBy = EventsResource.ListRequest.OrderByEnum.StartTime; Events events = request1.Execute(); List <Showcase.ShowcaseService.Contract.Event> eventList = new List <Showcase.ShowcaseService.Contract.Event>(); if (events.Items != null && events.Items.Count > 0) { foreach (var eventItem in events.Items) { eventList.Add(new Showcase.ShowcaseService.Contract.Event { Title = eventItem.Summary, StartTime = eventItem.Start.DateTime.ToString(), EndTime = eventItem.End.DateTime.ToString() }); } } CalendarResponse response = new CalendarResponse(); response.Events = eventList; return(response); } catch (Exception e) { throw; } }
private CalendarResponse SortResults(CalendarResponse response) { response.centers = response.centers.ToList().OrderBy(center => center.sessions.Select(session => session.date).Min()); return(response); }
/// <summary>Responsd to Calendar Event</summary> /// <remarks>Requires SSO Authentication, using "respond_calendar_events" scope</remarks> /// <param name="CharacterID">(Int32) Character ID</param> /// <param name="EventID">(Int32) Event ID</param> /// <param name="Response">(CalendarResponse) Response</param> /// <returns>EsiRequest</returns> public EsiRequest RespondToEvent(int CharacterID, int EventID, CalendarResponse Response) { return(RespondToEvent(CharacterID, EventID, Response.Value)); }