Exemplo n.º 1
0
 public static Event mapEventJsonToEvent(JsonObject eventJson)
 {
     Event eventObj = new Event();
     eventObj.id = eventJson.GetNamedString("id");
     eventObj.title = eventJson.GetNamedString("title");
     eventObj.description = eventJson.GetNamedString("description");
     eventObj.date = DateTime.Parse(eventJson.GetNamedString("dueDate"));
     eventObj.type = eventJson.GetNamedString("type");
     eventObj.description = "Bacon ipsum dolor sit amet meatloaf tail doner, sausage pig jowl flank chicken beef ribs drumstick leberkas ham rump ball tip prosciutto. Boudin pig prosciutto, leberkas ball tip meatloaf ham hock hamburger ribeye salami beef jerky.";
     return eventObj;
 }
        /// <summary>
        /// Get all the events for the sections the student is in
        /// </summary>
        /// <param name="studentId"></param>
        /// <returns></returns>
        private async Task<List<Event>> getEventsByStudent(string studentId)
        {
            List<Event> studentEvents = new List<Event>();

            List<FeedItem> feeds = new List<FeedItem>();

            var studentCustomAssociations = Constants.Student.CUSTOM.Replace(Constants.Student.STUDENT_ID, studentId);
            var studentCustom = await Utility.GetData(string.Format("{0}{1}", Constants.API_URI, studentCustomAssociations), App.ACCESSTOKEN);
            var studentCustomJson = JsonObject.Parse(studentCustom);

            var studentFeedsArray = studentCustomJson.GetNamedArray("news");
            foreach (var feedItem in studentFeedsArray)
            {
                FeedItem fi = Mapper.mapFeedItemJsonToFeedItem(feedItem.GetObject());
                try
                {
                    if (fi.Type.Equals(FeedItem.EVENT))
                    {
                        Event e = new Event()
                        {
                            title = fi.Title,
                            id = fi.Id,
                            description = "Bacon ipsum dolor sit amet meatloaf tail doner, sausage pig jowl flank chicken beef ribs drumstick leberkas ham rump ball tip prosciutto. Boudin pig prosciutto, leberkas ball tip meatloaf ham hock hamburger ribeye salami beef jerky.",
                            date = fi.DueDate,
                            map = "Assets/map.png"
                        };
                        studentEvents.Add(e);
                    }
                }
                catch (Exception e)
                {
                    // Do nothing
                }
            }

            return studentEvents;  
        }