示例#1
0
        public MessageViewModel(NavigationService navigationService, IRestApiService apiService)
        {
            _navigationService = navigationService ?? throw new NullReferenceException();
            _apiService        = apiService ?? throw new NullReferenceException();

            SendMessageCommand = ReactiveCommand.CreateFromTask(async() =>
            {
                if (String.IsNullOrWhiteSpace(MyMessage))
                {
                    return;
                }
                try
                {
                    var cont = App.Container.Resolve <ApplicationDataContainer>();
                    await _apiService.SendMessage(_selectedMatchId, new MessageDto {
                        Data = MyMessage
                    }, cont.Values["AuthToken"] as string);
                    MyMessage = String.Empty;
                    await GetMessage(_selectedMatchId);
                }
                catch (Exception e)
                {
                    await new MessageDialog(e.Message).ShowAsync();
                }
            });
        }
示例#2
0
        public AuthViewModel(NavigationService navigationService, IRestApiService apiService, FbAuthService authService)
        {
            _navigationService = navigationService ?? throw new NullReferenceException();
            _apiService        = apiService ?? throw new NullReferenceException();
            _fbAuthService     = authService ?? throw new NullReferenceException();

            var container = App.Container.Resolve <ApplicationDataContainer>();

            SelectedLang = container.Values["appLang"] as string;
            SignInWithFacebookCommand = ReactiveCommand.CreateFromTask(async() =>
            {
                var res = await _fbAuthService.SignInWithFacebook();
                if (res == true)
                {
                    try
                    {
                        var aut = await _apiService.SignInWithFacebook(_fbAuthService.AccessToken);
                        if (aut.Succeeded == true)
                        {
                            container.Values["AuthToken"] = "Bearer " + aut.AuthToken;
                            _navigationService.Navigate_App(typeof(MainPageView));
                            return;
                        }
                        await new MessageDialog(aut.Error).ShowAsync();
                    }
                    catch (Exception e)
                    {
                        await new MessageDialog(e.Message).ShowAsync();
                    }
                }
                await new MessageDialog("Error").ShowAsync();
            });
        }
示例#3
0
        public SignInViewModel(NavigationService navigationService, IRestApiService apiService)
        {
            _navigationService = navigationService ?? throw new NullReferenceException();
            _apiService        = apiService ?? throw new NullReferenceException();

            var valid = this.WhenAnyValue(x => x.Email, x => x.Password, (email, password) =>
                                          new Regex(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$").IsMatch(email) &&
                                          new Regex(@"([a-zA-Z0-9]{6,})").IsMatch(password));

            SignInCommand = ReactiveCommand.CreateFromTask(async() => {
                var dto = new SignInDto {
                    Email = this.Email, Password = this.Password
                };
                try
                {
                    var res = await _apiService.SignIn(dto);
                    if (res.Succeeded == true)
                    {
                        var container = App.Container.Resolve <ApplicationDataContainer>();
                        container.Values["AuthToken"] = "Bearer " + res.AuthToken;
                        _navigationService.Navigate_App(typeof(MainPageView));
                        return;
                    }
                    await new MessageDialog($"Error: {res.Error}").ShowAsync();
                }
                catch (Exception e)
                {
                    await new MessageDialog(e.Message).ShowAsync();
                }
            }, valid);
        }
        public UserControllerTests()
        {
            accountService      = Mock.Create <IAccountService>();
            nomenclatureService = Mock.Create <INomenclatureService>();
            restApiService      = Mock.Create <IRestApiService>();
            roleService         = Mock.Create <IRoleService>();
            userMailService     = Mock.Create <IUserMailService>();
            userService         = Mock.Create <IUserService>();
            groupService        = Mock.Create <IGroupService>();

            userController = new UserController(
                Logger,
                Mapper,
                ContextManager,
                ResourceManager,
                userService,
                userMailService,
                accountService,
                nomenclatureService,
                roleService,
                restApiService,
                groupService);

            InitContext();
        }
        public HomeControllerTests()
        {
            nomenclatureService = Mock.Create <INomenclatureService>();
            publicationService  = Mock.Create <IPublicationService>();
            adminService        = Mock.Create <IAdminService>();
            cacheService        = Mock.Create <ICacheService>();
            faqService          = Mock.Create <IFaqService>();
            cmsService          = Mock.Create <ICmsService>();
            restApiService      = Mock.Create <IRestApiService>();
            providerService     = Mock.Create <IProviderService>();

            homeController = new HomeController(
                Logger,
                Mapper,
                ContextManager,
                nomenclatureService,
                publicationService,
                adminService,
                cacheService,
                faqService,
                cmsService,
                restApiService,
                providerService);
            InitContext();
        }
示例#6
0
 public MusicBrainzMetadataUpdater(IRestApiService restApiService)
 {
     _restApiService = restApiService;
     _restApiService.SetHeader("Accept", "application/xml");
     _restApiService.SetHeader("User-Agent", UserAgent);
     _restApiService.SetRateLimiter(1);
 }
 public MusicBrainzMetadataUpdater(IRestApiService restApiService)
 {
     _restApiService = restApiService;
     _restApiService.SetHeader("Accept", "application/xml");
     _restApiService.SetHeader("User-Agent", UserAgent);
     _restApiService.SetRateLimiter(1);
 }
示例#8
0
        public MatchViewModel(NavigationService navigationService, IRestApiService apiService)
        {
            _navigationService = navigationService ?? throw new NullReferenceException();;
            _apiService        = apiService ?? throw new NullReferenceException();

            var cont = App.Container.Resolve <ApplicationDataContainer>();

            var valid = this.WhenAnyValue(x => x.Error404, (q) => q == true);

            LikeCommand = ReactiveCommand.CreateFromTask(async() =>
            {
                try
                {
                    await _apiService.Liked(_id, cont.Values["AuthToken"] as string);
                    await GetNewPersone();
                }
                catch (Exception e)
                {
                    await new MessageDialog(e.Message).ShowAsync();
                }
            });
            PassCommand = ReactiveCommand.CreateFromTask(async() =>
            {
                try
                {
                    await _apiService.Liked(_id, cont.Values["AuthToken"] as string);
                    await GetNewPersone();
                }
                catch (Exception e)
                {
                    await new MessageDialog(e.Message).ShowAsync();
                }
            });
            SaveSettingCommand = ReactiveCommand.CreateFromTask(async() =>
            {
                try
                {
                    await _apiService.SetSearchParameters(new SearchParameterDto {
                    }, cont.Values["AuthToken"] as string);
                    await GetNewPersone();
                }
                catch (Exception e)
                {
                    await new MessageDialog(e.Message).ShowAsync();
                }
            });

            LocationCommand = ReactiveCommand.CreateFromTask(async() =>
            {
                try
                {
                    var loc = App.Container.Resolve <LocationService>();
                    await loc.GetAccess();
                }
                catch (Exception)
                {
                }
            });
        }
示例#9
0
 public DashboardViewModel(IConnectionService connectionService, IDialogService dialogService, IPhotoService photoService, IProgressDialogService progressDialogService, IRestApiService restApiService)
 {
     _connectionService     = connectionService;
     _dialogService         = dialogService;
     _photoService          = photoService;
     _progressDialogService = progressDialogService;
     _restApiService        = restApiService;
 }
        public RestApiDemo(IRestApiService service)
        {
            InitializeComponent();
            this._service            = service;
            VehiclesGrid.ItemsSource = this.List;

            this.List.CollectionChanged += List_CollectionChanged;
        }
示例#11
0
        public void SetUp()
        {
            var client = new HttpClient {
                BaseAddress = new Uri(ApiBaseAddress),
                Timeout     = TimeSpan.FromMinutes(1),
            };

            _apiService = RestService.For <IRestApiService>(client);
        }
 public FetchService(
     ILogger <FetchService> logger,
     IRestApiService restApiService,
     IOptions <CubicWeightSettings> settings)
 {
     _logger         = logger;
     _restApiService = restApiService;
     _settings       = settings.Value;
 }
示例#13
0
 public void Init(string apiBaseAddress, string accessToken)
 {
     _apiService = RestService.For <IRestApiService>(new HttpClient(new HttpLoggingHandler())
     {
         BaseAddress = new Uri(apiBaseAddress),
         Timeout     = TimeSpan.FromMinutes(1)
     });
     _accessToken = accessToken;
 }
 public FetchService(
     ILogger <FetchService> logger,
     IExceptionFactory exceptionFactory,
     IRestApiService restApiService,
     IOptions <JsonConsumerSettings> settings)
 {
     _logger           = logger;
     _exceptionFactory = exceptionFactory;
     _restApiService   = restApiService;
     _settings         = settings.Value;
 }
 public GroupsViewController(
     ILogger logger,
     IMapper mapper,
     IDbContextManager contextManager,
     IGroupService groupService,
     IRestApiService restApiService)
     : base(logger, mapper, contextManager)
 {
     this.groupService   = groupService;
     this.restApiService = restApiService;
 }
示例#16
0
 public GroupController(
     ILogger logger,
     IMapper mapper,
     IDbContextManager contextManager,
     IResourceManager resource,
     IRestApiService restApiService,
     IGroupService groupService)
     : base(logger, mapper, contextManager, resource, Resource.Organizations)
 {
     this.restApiService = restApiService;
     this.groupService   = groupService;
 }
示例#17
0
        public static Task HandleHttpRequest(this IRestApiService restApiService, HttpContext context, string protocolName)
        {
            if (restApiService.TryGetHandlerProtocol <IHttpMessageProtocolInterface>(
                    context.Request.Path,
                    protocolName,
                    out IHttpMessageProtocolInterface protocol))
            {
                return(protocol.HandleRequest(context));
            }

            context.Response.StatusCode = (int)HttpStatusCode.NotFound;
            return(Task.CompletedTask);
        }
示例#18
0
        public SettingViewModel(NavigationService navigationService, IRestApiService apiService)
        {
            _navigationService = navigationService ?? throw new NullReferenceException();
            _apiService        = apiService ?? throw new NullReferenceException();

            var container = App.Container.Resolve <ApplicationDataContainer>();

            LogoutCommand = ReactiveCommand.Create(() =>
            {
                container.Values["AuthToken"] = null;
                _navigationService.Navigate_App(typeof(Auth));
            });
        }
示例#19
0
 public AuthenticationProvider(
     IMapper mapper,
     IDbContextManager contextManager,
     IAccountService accountService,
     IUserService userService,
     IRestApiService restApiService,
     ILogger logger)
 {
     this.mapper         = mapper;
     this.contextManager = contextManager;
     this.accountService = accountService;
     this.userService    = userService;
     this.restApiService = restApiService;
     this.logger         = logger;
 }
示例#20
0
        public AuthorControllerBaseTest()
        {
            Mock <IUrlHelper> mockUrlHelper     = SetUpMockUrlHelper();
            ControllerContext controllerContext = SetUpControllerContext();

            SetUpMapper();


            _restApiService = restApiServiceMoq.Object;

            _authorsController = new AuthorsController(_restApiService, _mapper)
            {
                ControllerContext = controllerContext,
                Url = mockUrlHelper.Object
            };
        }
示例#21
0
        public FileDeliveryJob(
            IDeliveryJobRepository deliveryJobRepository,
            IExtractFileService extractFileService,
            IRestApiService restApiService)
        {
            var jobInterval = ConfigurationManager.AppSettings["job:FileDeliveryJobInterval"];

            if (string.IsNullOrEmpty(jobInterval))
            {
                throw new ConfigurationErrorsException("Please add 'job:FileDeliveryJobInterval' settigns to .config file.");
            }

            JobInterval = int.Parse(jobInterval);

            _deliveryJobRepo    = deliveryJobRepository;
            _extractFileService = extractFileService;
            _restApiService     = restApiService;
        }
示例#22
0
 public AccountController(
     ILogger logger,
     IMapper mapper,
     IDbContextManager contextManager,
     IAccountService accountService,
     IAuthenticationProvider authenticationProvider,
     IUserService userService,
     IUserMailService userMailService,
     ICaptchaService captchaService,
     IRestApiService restApiService)
     : base(logger, mapper, contextManager)
 {
     this.accountService         = accountService;
     this.authenticationProvider = authenticationProvider;
     this.userService            = userService;
     this.userMailService        = userMailService;
     this.captchaService         = captchaService;
     this.restApiService         = restApiService;
 }
        public TemperatureMonitorViewModel(
            IRestApiService restApiService,
            ITemperatureSensorService temperatureSensorService,
            ITableStorageService tableStorageService)
        {
            _restApiService           = restApiService;
            _temperatureSensorService = temperatureSensorService;
            _tableStorageService      = tableStorageService;

            _cancellationTokenSource = new CancellationTokenSource();

            IsLoading = true;
            Summary   = new ObservableCollection <SensorData>();
            Date      = DateTime.Now;

            RefreshCommand      = new Command(async() => await RefreshAsync());
            NextDateCommand     = new Command(async() => await NextDateAsync());
            PreviousDateCommand = new Command(async() => await PreviousDateAsync());
        }
 public AccountControllerTests()
 {
     accountService         = Mock.Create <IAccountService>();
     authenticationProvider = Mock.Create <IAuthenticationProvider>();
     captchaService         = Mock.Create <ICaptchaService>();
     restApiService         = Mock.Create <IRestApiService>();
     userMailService        = Mock.Create <IUserMailService>();
     userService            = Mock.Create <IUserService>();
     accountController      = new AccountController(
         Logger,
         Mapper,
         ContextManager,
         accountService,
         authenticationProvider,
         userService,
         userMailService,
         captchaService,
         restApiService);
     InitContext();
 }
示例#25
0
        public RegisterViewModel(NavigationService navigationService, IRestApiService apiService)
        {
            _navigationService = navigationService ?? throw new NullReferenceException();
            _apiService        = apiService ?? throw new NullReferenceException();

            var valid = this.WhenAnyValue(
                x => x.Email, x => x.Password, x => x.Name, x => x.DateOfBirth, x => x.Gender,
                (email, password, name, date, gender) =>
                new Regex(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$").IsMatch(email) &&
                new Regex(@"([a-zA-Z0-9]{6,})").IsMatch(password) &&
                new Regex(@"([a-z]{1,})").IsMatch(password) &&
                new Regex(@"([A-Z]{1,})").IsMatch(password) &&
                new Regex(@"([0-9]{1,})").IsMatch(password) &&
                new Regex(@"([a-zA-Z]{2,})").IsMatch(name) &&
                gender is Gender
                );

            RegisterCommand = ReactiveCommand.CreateFromTask(async() => {
                var gender = this.Gender == SharedLibrary.Models.Gender.Male ? SharedLibrary.Models.Gender.Male : SharedLibrary.Models.Gender.Female;
                var dto    = new RegisterDto {
                    Email = this.Email, Name = this.Name, Password = this.Password, Gender = gender, DateOfBirth = this.DateOfBirth.DateTime
                };
                try
                {
                    var res = await _apiService.Register(dto);
                    if (res.Succeeded == true)
                    {
                        var container = App.Container.Resolve <ApplicationDataContainer>();
                        container.Values["AuthToken"] = "Bearer " + res.AuthToken;
                        _navigationService.Navigate_App(typeof(MainPageView));
                        return;
                    }
                    await new MessageDialog($"Error: {res.Error}").ShowAsync();
                }
                catch (Exception e)
                {
                    await new MessageDialog($"Error: {e.Message}").ShowAsync();
                }
            }, valid);
        }
示例#26
0
 public UserController(
     ILogger logger,
     IMapper mapper,
     IDbContextManager contextManager,
     IResourceManager resource,
     IUserService userService,
     IUserMailService userMailService,
     IAccountService accountService,
     INomenclatureService nomenclatureService,
     IRoleService roleService,
     IRestApiService restApiService,
     IGroupService groupService)
     : base(logger, mapper, contextManager, resource, Resource.Users)
 {
     this.userService         = userService;
     this.userMailService     = userMailService;
     this.accountService      = accountService;
     this.nomenclatureService = nomenclatureService;
     this.roleService         = roleService;
     this.restApiService      = restApiService;
     this.groupService        = groupService;
 }
示例#27
0
 public HomeController(
     ILogger logger,
     IMapper mapper,
     IDbContextManager contextManager,
     INomenclatureService nomenclatureService,
     IPublicationService publicationService,
     IAdminService adminService,
     ICacheService cacheService,
     IFaqService faqService,
     ICmsService cmsService,
     IRestApiService restApiService,
     IProviderService providerService)
     : base(logger, mapper, contextManager)
 {
     this.nomenclatureService = nomenclatureService;
     this.publicationService  = publicationService;
     this.adminService        = adminService;
     this.cacheService        = cacheService;
     this.faqService          = faqService;
     this.cmsService          = cmsService;
     this.restApiService      = restApiService;
     this.providerService     = providerService;
 }
示例#28
0
 public BusLocationManager(IRestApiService restApiService)
 {
     _restApiService = restApiService;
 }
 public ThetvdbTvShowMetadataUpdater(IRestApiService restApiService)
 {
     _restApiService = restApiService;
 }
示例#30
0
 public PhotoProvider(SortModel sort)
 {
     _restService  = Mvx.IoCProvider.Resolve <IRestApiService>();
     _photoService = Mvx.IoCProvider.Resolve <IPhotoService>();
 }
示例#31
0
 public MainPageViewModel(NavigationService navigationService, IRestApiService apiService)
 {
     _navigationService = navigationService ?? throw new NullReferenceException();
     _apiService        = apiService ?? throw new NullReferenceException();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ImdbMovieSynopsisService"/> class.
 /// </summary>
 /// <param name="restApiService">IMDB API service.</param>
 public ImdbMovieSynopsisService(IRestApiService restApiService)
 {
     _restApiService = restApiService;
 }
示例#33
0
        public ProfileViewModel(NavigationService navigationService, IRestApiService apiService)
        {
            _navigationService = navigationService ?? throw new NullReferenceException();
            _apiService        = apiService ?? throw new NullReferenceException();

            SaveCommand = ReactiveCommand.CreateFromTask(async() =>
            {
                try
                {
                    var cont = App.Container.Resolve <ApplicationDataContainer>();
                    var ret  = await _apiService.SetProfileData(new UserDataSettingsDto {
                        Description = this.Description, Job = this.Job, School = this.School
                    }, cont.Values["AuthToken"] as string);
                    Description = ret.Description;
                    Job         = ret.Job;
                    School      = ret.School;
                }
                catch (Exception e)
                {
                    await new MessageDialog(e.Message).ShowAsync();
                }
            });

            DeleteCommand = ReactiveCommand.CreateFromTask(async() =>
            {
                try
                {
                    if (SelectedImage == null)
                    {
                        return;
                    }
                    var cont      = App.Container.Resolve <ApplicationDataContainer>();
                    var ret       = await _apiService.DeletePhoto(SelectedImage.Id, cont.Values["AuthToken"] as string);
                    SelectedImage = null;
                    var list      = new SourceList <PhotoDto>();
                    list.AddRange(ret);
                    Photos = list;
                    SetMainImage(ret);
                }
                catch (Exception e)
                {
                    await new MessageDialog(e.Message).ShowAsync();
                }
            });

            SetMainCommand = ReactiveCommand.CreateFromTask(async() =>
            {
                try
                {
                    if (SelectedImage == null)
                    {
                        return;
                    }
                    var cont = App.Container.Resolve <ApplicationDataContainer>();
                    var ret  = await _apiService.SetMainPhoto(SelectedImage.Id, cont.Values["AuthToken"] as string);
                    var list = new SourceList <PhotoDto>();
                    list.AddRange(ret);
                    Photos = list;
                    SetMainImage(ret);
                }
                catch (Exception e)
                {
                    await new MessageDialog(e.Message).ShowAsync();
                }
            });
        }
 public FanartTvMusicImageUpdater(IRestApiService restApiService)
 {
     _restApiService = restApiService;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ThemoviedbMovieMetadataUpdater"/> class.
 /// </summary>
 /// <param name="restApiService">The rest API service.</param>
 public ThemoviedbMovieMetadataUpdater(IRestApiService restApiService)
 {
     _restApiService = restApiService;
 }
 public ImdbMovieSynopsisServiceTests()
 {
     _restApiService = Substitute.For<IRestApiService>();
     _service = new ImdbMovieSynopsisService(_restApiService);
 }