Exemple #1
0
        public async Task <UniversityDto> GetTeacherStructure()
        {
            var url      = _apiUrlsService.GetTeachersStructureUrl();
            var response = await RequestSender.Get <StructureDto>(url);

            return(response.University);
        }
Exemple #2
0
        private async Task <EventsStatisticDto> GetStatisticAsync(
            string targetId,
            DateTime from,
            DateTime to,
            Func <string, long, long, string> urlProvider)
        {
            var result = new EventsStatisticDto();

            from = from.AddDays(-1);
            var fromAsSeconds = ToUnixDateTime(from);
            var toAsSeconds   = ToUnixDateTime(to);

            var url      = urlProvider(targetId, fromAsSeconds, toAsSeconds);
            var response = await RequestSender.Get <EventResultDto>(url);

            foreach (var item in response.Events)
            {
                var datetime = ToUtcDateTime(item.StartTime);
                var date     = datetime.Date;

                var dailyOccupation = result.DailyOccupations.SingleOrDefault(o => o.Date == date);
                if (dailyOccupation == null)
                {
                    dailyOccupation = new DailyOccupationDto {
                        Date = date, EventsCount = 1
                    };
                    result.DailyOccupations.Add(dailyOccupation);
                }
                else
                {
                    dailyOccupation.EventsCount++;
                }

                var eventType      = response.EventTypes.Single(t => t.Id == item.Type).Type;
                var eventTypeCount = result.EventTypeCounts.SingleOrDefault(t => t.Type == eventType);
                if (eventTypeCount == null)
                {
                    eventTypeCount = new EventTypeCountDto {
                        Type = eventType, Count = 1
                    };
                    result.EventTypeCounts.Add(eventTypeCount);
                }
                else
                {
                    eventTypeCount.Count++;
                }
            }

            return(result);
        }
Exemple #3
0
 private async Task <TResult> GetResult <TResult>(string address)
 {
     try
     {
         return(await CallManager.Call(async() =>
         {
             var resultStr = await RequestSender.Get(address);
             return JsonConvert.DeserializeObject <TResult>(resultStr);
         }));
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw;
     }
 }