Mercurial > altnet-hispano
comparison Agendas/trunk/src/Agendas.Google/GCalendarAdapter.cs @ 130:0ea32a748453
Se termina el publicador via el calendario de google, además se realizan las pruebas unitarias.
author | alabra |
---|---|
date | Sun, 10 Jul 2011 18:50:11 -0400 |
parents | 34b2f85aecab |
children | 734d3f0853bf |
comparison
equal
deleted
inserted
replaced
129:a6d20ea228a5 | 130:0ea32a748453 |
---|---|
7 public class GCalendarAdapter : IGCalendarAdapter | 7 public class GCalendarAdapter : IGCalendarAdapter |
8 { | 8 { |
9 private readonly CalendarService _service; | 9 private readonly CalendarService _service; |
10 private readonly Uri _feedUri; | 10 private readonly Uri _feedUri; |
11 | 11 |
12 public void CreateEvent(string title, DateTime startEvent, DateTime endEvent, string location, string summary) | 12 public bool CreateEvent(IGEventDetail gEventDetail, out string message) |
13 { | 13 { |
14 var entry = new EventEntry | 14 try |
15 { | 15 { |
16 Title = { Text = title }, | 16 var entry = new EventEntry |
17 Content = { Content = summary } | 17 { |
18 }; | 18 Title = { Text = gEventDetail.Title }, |
19 Content = { Content = gEventDetail.Summary } | |
20 }; | |
19 | 21 |
20 var eventLocation = new Where | 22 var eventLocation = new Where |
21 { | 23 { |
22 ValueString = location | 24 ValueString = gEventDetail.Location |
23 }; | 25 }; |
24 | 26 |
25 entry.Locations.Add(eventLocation); | 27 entry.Locations.Add(eventLocation); |
26 | 28 |
27 var eventTime = new When(startEvent, endEvent); | 29 var eventTime = new When(gEventDetail.StartEvent, gEventDetail.EndEvent); |
28 entry.Times.Add(eventTime); | 30 entry.Times.Add(eventTime); |
29 | 31 |
30 _service.Insert(_feedUri, entry); | 32 _service.Insert(_feedUri, entry); |
33 message = "Event create successful"; | |
34 return true; | |
35 } | |
36 catch (Exception exception) | |
37 { | |
38 message = exception.Message; | |
39 return false; | |
40 } | |
31 } | 41 } |
32 | 42 |
33 public void DeleteEvent(DateTime startEvent, DateTime endEvent) | 43 public bool DeleteEvent(DateTime startEvent, DateTime endEvent, out string message) |
34 { | 44 { |
35 var myQuery = new EventQuery | 45 try |
36 { | 46 { |
37 StartTime = startEvent, | 47 var myQuery = new EventQuery |
38 EndTime = endEvent, | 48 { |
39 Uri = _feedUri | 49 StartTime = startEvent, |
40 }; | 50 EndTime = endEvent, |
51 Uri = _feedUri | |
52 }; | |
41 | 53 |
42 var myResultsFeed = _service.Query(myQuery); | 54 var myResultsFeed = _service.Query(myQuery); |
43 if (myResultsFeed.Entries.Count > 0) | 55 if (myResultsFeed.Entries.Count > 0) |
44 myResultsFeed.Entries[0].Delete(); | 56 { |
57 myResultsFeed.Entries[0].Delete(); | |
58 message = "Event delete successful"; | |
59 return true; | |
60 } | |
61 | |
62 message = "Event not found"; | |
63 return false; | |
64 } | |
65 catch (Exception exception) | |
66 { | |
67 message = exception.Message; | |
68 return false; | |
69 } | |
45 } | 70 } |
46 | 71 |
47 public GCalendarAdapter(string applicationName ,string userName, string password, string calendarId) | 72 public GCalendarAdapter(string applicationName ,string userName, string password, string calendarId) |
48 { | 73 { |
49 _service = new CalendarService(applicationName); | 74 _service = new CalendarService(applicationName); |