Пример #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);
 }