Example #1
0
        public static Event ToEvent(this CommonClasses.GoogleEvent i)
        {
            var o = new Event();

            o.Id = i.ID;
            try
            {
                //var rd = JsonConvert.DeserializeObject<CommonClasses.GoogleEvent.RichDescription>(o.Description);
                //o.Description = rd.Description;
                //o.ImageUris = rd.ImageUris;
            }
            catch
            {
                o.Description = i.Description;
            }
            o.Summary        = i.Name;
            o.Location       = i.Luogo;
            o.Start.DateTime = i.StartDate;
            o.End.DateTime   = i.EndDate;
            try
            {
                if (string.IsNullOrWhiteSpace(i.AttachmentsSerialization) == false)
                {
                    o.Attachments = JsonConvert.DeserializeObject <List <EventAttachment> >(i.AttachmentsSerialization);
                }
            }
            catch { }
            return(o);
        }
Example #2
0
        public static CommonClasses.GoogleEvent ToGoogleEvent(this Event i)
        {
            var o = new CommonClasses.GoogleEvent();

            o.ID = i.Id;
            try
            {
                var rd = JsonConvert.DeserializeObject <CommonClasses.GoogleEvent.RichDescription>(o.Description);
                o.Description = rd.Description;
                o.ImageUris   = rd.ImageUris;
            }
            catch {
                o.Description = i.Description;
            }
            o.Name      = i.Summary;
            o.Luogo     = i.Location;
            o.StartDate = i.Start.DateTime ?? DateTime.MinValue;
            o.EndDate   = i.End.DateTime ?? DateTime.MinValue;

            #region ImageDeprecated

            if (i.Attachments != null)
            {
                foreach (var attachment in i.Attachments)
                {
                    if ((attachment.MimeType ?? "").Contains("image/") || (attachment.Title ?? "").Contains(".png") || (attachment.Title ?? "").Contains(".jpg"))
                    {
                        o.ImageUris.Add(MainClass.ExternalAccessBaseUri + MainClass.LoftPrefix + "file/get/" + attachment.FileId);
                        Debug.WriteLine("File id: " + attachment.FileId);
                    }
                }
            }

            #endregion
            return(o);
        }