<commit_before>﻿using System;
using System.Collections.ObjectModel;
using System.Net.Http;
using System.Threading.Tasks;
using AugmentedSzczecin.Events;
using AugmentedSzczecin.Interfaces;
using AugmentedSzczecin.Models;
using Caliburn.Micro;
using Newtonsoft.Json;

namespace AugmentedSzczecin.Services
{
    public class PointOfInterestService : IPointOfInterestService
    {
        private readonly IEventAggregator _eventAggregator;
        private readonly IHttpService _httpService;
        private readonly IAccountService _accountService;

        public PointOfInterestService(IEventAggregator eventAggregator, IHttpService httpService, IAccountService accountService)
        {
            _eventAggregator = eventAggregator;
            _httpService = httpService;
            _accountService = accountService;
        }

        private ObservableCollection<PointOfInterest> _pointOfInterestList = new ObservableCollection<PointOfInterest>();
        public ObservableCollection<PointOfInterest> PointOfInterestList
        {
            get { return _pointOfInterestList; }
            set
            {
                if (_pointOfInterestList != null && _pointOfInterestList != value)
                {
                    _pointOfInterestList = value;
                }
            }
        }

        public async void LoadPlaces()
        {
            try
            {
                PointOfInterestList = await _httpService.GetPointOfInterestList();
                _eventAggregator.PublishOnUIThread(new PointOfInterestLoadedEvent() { PointOfInterestList = PointOfInterestList });
            }
            catch (Exception e)
            {
                _eventAggregator.PublishOnUIThread(new PointOfInterestLoadFailedEvent() { PointOfInterestLoadException = e });
            }
        }

        public async void LoadPoIs(double latitude, double longitude, int radius, CategoryType category)
        {
            try
            {
                PointOfInterestList = await _httpService.GetPointOfInterestList(latitude, longitude, radius, category);
                _eventAggregator.PublishOnUIThread(new PointOfInterestLoadedEvent() { PointOfInterestList = PointOfInterestList });
            }
            catch (Exception e)
            {
                _eventAggregator.PublishOnUIThread(new PointOfInterestLoadFailedEvent() { PointOfInterestLoadException = e });
            }
        }

        public async void AddPointOfInterest(PointOfInterest poi)
        {
            try
            {
                await _httpService.AddPointOfInterest(poi, _accountService.GetUserEmail(), _accountService.GetUserPassword());
            }
            catch (Exception e)
            {
            }
        }
    }
}<commit_msg>Added statements for eventhandling - success or failed added PointOfInterest<commit_after>﻿using System;
using System.Collections.ObjectModel;
using System.Net.Http;
using System.Threading.Tasks;
using Windows.ApplicationModel.Resources;
using AugmentedSzczecin.Events;
using AugmentedSzczecin.Interfaces;
using AugmentedSzczecin.Models;
using Caliburn.Micro;
using Newtonsoft.Json;

namespace AugmentedSzczecin.Services
{
    public class PointOfInterestService : IPointOfInterestService
    {
        private readonly IEventAggregator _eventAggregator;
        private readonly IHttpService _httpService;
        private readonly IAccountService _accountService;

        public PointOfInterestService(IEventAggregator eventAggregator, IHttpService httpService, IAccountService accountService)
        {
            _eventAggregator = eventAggregator;
            _httpService = httpService;
            _accountService = accountService;
        }

        private ObservableCollection<PointOfInterest> _pointOfInterestList = new ObservableCollection<PointOfInterest>();
        public ObservableCollection<PointOfInterest> PointOfInterestList
        {
            get { return _pointOfInterestList; }
            set
            {
                if (_pointOfInterestList != null && _pointOfInterestList != value)
                {
                    _pointOfInterestList = value;
                }
            }
        }

        public async void LoadPlaces()
        {
            try
            {
                PointOfInterestList = await _httpService.GetPointOfInterestList();
                _eventAggregator.PublishOnUIThread(new PointOfInterestLoadedEvent() { PointOfInterestList = PointOfInterestList });
            }
            catch (Exception e)
            {
                _eventAggregator.PublishOnUIThread(new PointOfInterestLoadFailedEvent() { PointOfInterestLoadException = e });
            }
        }

        public async void LoadPoIs(double latitude, double longitude, int radius, CategoryType category)
        {
            try
            {
                PointOfInterestList = await _httpService.GetPointOfInterestList(latitude, longitude, radius, category);
                _eventAggregator.PublishOnUIThread(new PointOfInterestLoadedEvent() { PointOfInterestList = PointOfInterestList });
            }
            catch (Exception e)
            {
                _eventAggregator.PublishOnUIThread(new PointOfInterestLoadFailedEvent() { PointOfInterestLoadException = e });
            }
        }

        public async void AddPointOfInterest(PointOfInterest poi)
        {
            var loader = new ResourceLoader();
            var isPointOfInterestAdded = await _httpService.AddPointOfInterest(poi, _accountService.GetUserEmail(), _accountService.GetUserPassword());

            if (isPointOfInterestAdded)
            {
                _eventAggregator.PublishOnUIThread(new CreatePointOfInterestSuccessEvent() { SuccessMessage = loader.GetString("CreatePointOfInterestSuccessMessage") });
            }
            else
            {
                _eventAggregator.PublishOnUIThread(new CreatePointOfInterestFailedEvent() { FailureMessage = loader.GetString("CreatePointOfInterestFailureMessage") });
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.06163251817580965, 'fraction_numerical': 0.0, 'mean_word_length': 2.383454443823365, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '982996', 'n_tokens_mistral': 1554, 'n_tokens_neox': 1436, 'n_words': 281}