예제 #1
0
 public void Remove(Event eventToRemove)
 {
     try
     {
         Events?.Remove(eventToRemove);
         PersistenceFacade.DeleteEvent(eventToRemove);
     }
     catch (Exception)
     {
         throw new ArgumentException("Event doesnt exsist.");
     }
 }
예제 #2
0
        public void AddEvent(Event newEvent)
        {
            try
            {
                PersistenceFacade.PostEventToDb(newEvent);
                Events?.Add(newEvent);
            }
            catch (Exception ex)
            {
                throw new ArgumentException(ex.Message);
            }

        }
예제 #3
0
 public async void CreateEvent()
 {
     try
     {
         EventViewModel vm = EventVm;
         var dateTime = DateTimeConverter.DateTimeOffsetAndTimeSetToDateTime(vm.Date, vm.Time);
         Event newEvent = new Event(vm.Id, vm.Name, vm.Description, vm.Place, dateTime);
         EventVm.EventCatalog.AddEvent(newEvent);
     }
     catch (Exception ex)
     {
         await new MessageDialog(ex.Message).ShowAsync();
     }
 }
예제 #4
0
        public static async void DeleteEvent(Event dEvent)
        {
            HttpClientHandler handler = new HttpClientHandler();
            handler.UseDefaultCredentials = true;
            using (var client = new HttpClient(handler))
            {
                client.BaseAddress = new Uri(ServerUri);
                client.DefaultRequestHeaders.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                try
                {
                    await client.DeleteAsync("api/Events/" + dEvent.Id);
                }
                catch (Exception ex)
                {
                    throw new ArgumentException(ex.Message);
                }
            }
        }
예제 #5
0
        //private static string jsonFileName = "EventsAsJson.dat";
        //private static string xmlFileName = "EventsAsXml.dat";

        public static async void PostEventToDb(Event events)
        {
            HttpClientHandler handler = new HttpClientHandler();
            handler.UseDefaultCredentials = true;
            using (var client = new HttpClient(handler))
            {
                client.BaseAddress = new Uri(ServerUri);
                client.DefaultRequestHeaders.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                try
                {
                    await client.PostAsJsonAsync("api/Events", events);
                }
                catch (Exception ex)
                {
                    await new MessageDialog(ex.Message).ShowAsync();
                }
            }
        }
예제 #6
0
 public void SetSelectedEvent(Event ev)
 {
     EventViewModel.SelectedEvent = ev;
 }
예제 #7
0
 public void AddEvent(Event newEvent)
 {
     Events?.Add(newEvent);
     PersistenceFacade.PostEventToDb(newEvent);
 }