コード例 #1
0
        public App()
        {
            InitializeComponent();
            MainPage = new NavigationPage(new MainPage());
            var cs = new ConnectivityService();

            cs.ConnectivityEvent();
        }
コード例 #2
0
ファイル: HelperMethods.cs プロジェクト: zxbe/SplurgeStop
        public async static Task <PurchaseTransaction> ReloadPurchaseTransaction(PurchaseTransactionId id)
        {
            var connectionString = ConnectivityService.GetConnectionString("TEMP");
            var context          = new SplurgeStopDbContext(connectionString);
            var repository       = new PurchaseTransactionRepository(context);

            return(await repository.GetPurchaseTransactionFullAsync(id));
        }
コード例 #3
0
ファイル: HelperMethods.cs プロジェクト: zxbe/SplurgeStop
        public async static Task <bool> CheckIfStoreExists(StoreId id)
        {
            var connectionString = ConnectivityService.GetConnectionString("TEMP");
            var context          = new SplurgeStopDbContext(connectionString);
            var repository       = new StoreRepository(context);

            return(await repository.ExistsAsync(id));
        }
コード例 #4
0
        public async Task <bool> SignIn(string email, string password)
        {
            string token  = "";
            var    uri    = new Uri(Strings.SignInURL);
            bool   result = false;

            if (await ConnectivityService.IsConnected() == false)
            {
                Settings.ErrorMessage = Strings.noInternet;
                return(false);
            }

            Dictionary <string, string> data = new Dictionary <string, string>();

            data.Add("client_id", Keys.Auth0ApplicationNameClientId);
            data.Add("username", email);
            data.Add("password", password);
            data.Add("connection", Keys.AuthConnectionDZHouse);
            data.Add("grant_type", "password");
            data.Add("scope", "openid");

            client = GetClient();

            try
            {
                var json    = JsonConvert.SerializeObject(data);
                var content = new StringContent(json, Encoding.UTF8, "application/json");

                HttpResponseMessage response = null;

                response = await client.PostAsync(uri, content);

                if (response.IsSuccessStatusCode)
                {
                    var jsonString = await response.Content.ReadAsStringAsync();

                    var jsonObject = JObject.Parse(jsonString);
                    token              = jsonObject["id_token"].ToString();
                    result             = true;
                    Settings.AuthToken = token;
                }
                else
                {
                    var res = response.StatusCode.ToString();
                    Settings.ErrorMessage = Strings.noAccountFound;
                    result = false;
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                Settings.ErrorMessage = Strings.Oops;
                result = false;
            }

            return(result);
        }
コード例 #5
0
ファイル: APIDeviceHelper.cs プロジェクト: JabusKotze/DZHouse
        public async Task <bool> SendDeviceMessage(string deviceId, int gpioPin, string mode, int maxTicks, int timeSpan)
        {
            bool   result = false;
            string message;
            var    uri = new Uri(Strings.ManageDeviceAPI_URL + "/" + deviceId);

            if (await ConnectivityService.IsConnected() == false)
            {
                Settings.ErrorMessage = Strings.noInternet;
                return(result);
            }


            var data = new DeviceMessage
            {
                GpioPin  = gpioPin,
                Mode     = mode,
                MaxTicks = maxTicks,
                TimeSpan = timeSpan
            };

            client = GetClient();

            try
            {
                var json    = JsonConvert.SerializeObject(data);
                var content = new StringContent(json, Encoding.UTF8, "application/json");
                HttpResponseMessage response = null;

                response = await client.PostAsync(uri, content);

                if (response.IsSuccessStatusCode)
                {
                    var jsonString = await response.Content.ReadAsStringAsync();

                    var jsonObject = JObject.Parse(jsonString);
                    result = true;
                }
                else
                {
                    var jsonString = await response.Content.ReadAsStringAsync();

                    var jsonObject = JObject.Parse(jsonString);
                    message = jsonObject["message"].ToString();
                    result  = false;
                    Settings.ErrorMessage = message;
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                Settings.ErrorMessage = Strings.Oops;
            }

            return(result);
        }
コード例 #6
0
        public DbConnectivityTester(IMetroDialogService metroDialogService, string connString = null)
        {
            this.metroDialogService = metroDialogService;
            connectionString        = connString;

            if (connectionString is null)
            {
                connectionString = ConnectivityService.GetConnectionString();
            }
        }
コード例 #7
0
        public IContainer Bootstrap()
        {
            var builder = new ContainerBuilder();

            builder.RegisterType <DialogService>().As <IDialogService>();

            builder.RegisterAssemblyTypes(typeof(AuthorService).Assembly)
            .Where(type => type.Name.EndsWith("Service"))
            .AsClosedTypesOf(typeof(IDomainService <,>));

            builder.RegisterAssemblyTypes(typeof(AuthorsViewModel).Assembly)
            .Where(type => type.Name.EndsWith("ViewModel"))
            .Keyed <ISelectedViewModel>(c => c.Name);

            builder.RegisterAssemblyTypes(typeof(AuthorDetailViewModel).Assembly)
            .Where(type => type.Name.EndsWith("DetailViewModel"))
            .Keyed <IDetailViewModel>(c => c.Name);

            builder.RegisterAssemblyTypes(typeof(AuthorLookupDataService).Assembly)
            .Where(type => type.Name.EndsWith("LookupDataService"))
            .AsImplementedInterfaces()
            .WithParameter("imagePath", "");

            builder.RegisterType <ReportLookupDataService>().AsImplementedInterfaces();
            builder.RegisterAssemblyTypes(typeof(AnnualBookStatisticsReportViewModel).Assembly)
            .Where(type => type.Name.EndsWith("ReportViewModel"))
            .Keyed <IReport>(c => c.Name);

            builder.RegisterAssemblyTypes(typeof(AuthorRepository).Assembly)
            .Where(type => type.Name.EndsWith("Repository"))
            .AsImplementedInterfaces();

            Settings settings = GetSettings();

            builder.Register <ILogger>((_)
                                       => new LoggerConfiguration()
                                       .WriteTo.File(Path.Combine(settings.LogFilePath, "Log-{Date}.txt"), rollingInterval: RollingInterval.Day)
                                       .WriteTo.Seq(settings.LogServerUrl)
                                       .CreateLogger())
            .SingleInstance();

            var connectionString = ConnectivityService.GetConnectionString(settings.StartupDatabase);

            builder.RegisterType <BookOrganizer2DbContext>()
            .AsSelf()
            .WithParameter("connectionString", connectionString);

            builder.RegisterType <EventAggregator>().As <IEventAggregator>().SingleInstance();

            builder.RegisterType <MainWindow>().AsSelf().SingleInstance();
            builder.RegisterType <MainViewModel>().AsSelf().SingleInstance();

            return(builder.Build());
        }
コード例 #8
0
        public static Task CreateInvalidFormat()
        {
            var connectionString = ConnectivityService.GetConnectionString("TEMP");
            var context = new BookOrganizer2DbContext(connectionString);
            var repository = new FormatRepository(context);
            var formatService = new FormatService(repository);

            var formatId = new FormatId(SequentialGuid.NewSequentialGuid());
            var command = new Commands.Create { Id = formatId };

            return formatService.Handle(command);
        }
コード例 #9
0
 private void OpenPage(int page)
 {
     if (ConnectivityService.IsConnected())
     {
         Loading = true;
         DownloadService.DownloadComics(page);
     }
     else
     {
         DialogService.Alert("There is no network connection", "No Network Connection", "Ok");
     }
 }
コード例 #10
0
        public void IsConnected_ReturnsTrue_WhenNetworkAccessIsInternet()
        {
            // Arrange
            var connectivityMock = new ConnectivityMock();

            connectivityMock.SetNetworkAccess(NetworkAccess.Internet);

            // Act
            var connectivityService = new ConnectivityService(connectivityMock);

            // Assert
            Assert.True(connectivityService.IsConnected);
        }
コード例 #11
0
        public void IsConnected_ReturnsFalse_WhenNetworkAccessIsNone()
        {
            // Arrange
            var connectivityMock = new ConnectivityMock();

            connectivityMock.SetNetworkAccess(NetworkAccess.None);

            // Act
            var connectivityService = new ConnectivityService(connectivityMock);

            // Assert
            Assert.False(connectivityService.IsConnected);
        }
コード例 #12
0
        // DELETE
        public static Task RemoveLanguage(LanguageId id)
        {
            var connectionString = ConnectivityService.GetConnectionString("TEMP");
            var context          = new BookOrganizer2DbContext(connectionString);
            var repository       = new LanguageRepository(context);

            var languageService = new LanguageService(repository);
            var command         = new Commands.Delete
            {
                Id = id,
            };

            return(languageService.Handle(command));
        }
コード例 #13
0
        // DELETE
        public static Task RemoveFormat(FormatId id)
        {
            var connectionString = ConnectivityService.GetConnectionString("TEMP");
            var context = new BookOrganizer2DbContext(connectionString);
            var repository = new FormatRepository(context);

            var formatService = new FormatService(repository);
            var command = new Commands.Delete
            {
                Id = id,
            };

            return formatService.Handle(command);
        }
コード例 #14
0
        public static Task CreateInvalidAuthor()
        {
            var connectionString = ConnectivityService.GetConnectionString("TEMP");
            var context          = new BookOrganizer2DbContext(connectionString);
            var repository       = new AuthorRepository(context);
            var authorService    = new AuthorService(repository);

            var authorId = new AuthorId(SequentialGuid.NewSequentialGuid());
            var command  = new Commands.Create {
                Id = authorId
            };

            return(authorService.Handle(command));
        }
コード例 #15
0
        // DELETE
        public static Task RemoveAuthor(AuthorId id)
        {
            var connectionString = ConnectivityService.GetConnectionString("TEMP");
            var context          = new BookOrganizer2DbContext(connectionString);
            var repository       = new AuthorRepository(context);

            var authorService = new AuthorService(repository);
            var command       = new Commands.DeleteAuthor
            {
                Id = id,
            };

            return(authorService.Handle(command));
        }
コード例 #16
0
        // DELETE
        public static Task RemoveNationality(NationalityId id)
        {
            var connectionString = ConnectivityService.GetConnectionString("TEMP");
            var context          = new BookOrganizer2DbContext(connectionString);
            var repository       = new NationalityRepository(context);

            var nationalityService = new NationalityService(repository);
            var command            = new Commands.Delete
            {
                Id = id,
            };

            return(nationalityService.Handle(command));
        }
コード例 #17
0
ファイル: HelperMethods.cs プロジェクト: zxbe/SplurgeStop
        public async static Task RemoveStore(StoreId id)
        {
            var connectionString = ConnectivityService.GetConnectionString("TEMP");
            var context          = new SplurgeStopDbContext(connectionString);
            var repository       = new StoreRepository(context);
            var unitOfWork       = new EfCoreUnitOfWork(context);
            var service          = new StoreService(repository, unitOfWork);
            var storeController  = new StoreController(service);

            var updateCommand = new store.Commands.DeleteStore();

            updateCommand.Id = id;

            await storeController.DeleteStore(updateCommand);
        }
コード例 #18
0
        public static Task UpdateAuthorNationality(AuthorId authorId, NationalityId nationalityId)
        {
            var connectionString = ConnectivityService.GetConnectionString("TEMP");
            var context          = new BookOrganizer2DbContext(connectionString);
            var repository       = new AuthorRepository(context);

            var authorService = new AuthorService(repository);
            var command       = new Commands.SetNationality
            {
                Id            = authorId,
                NationalityId = nationalityId
            };

            return(authorService.Handle(command));
        }
コード例 #19
0
        public static Task UpdateAuthorNotes(AuthorId id, string notes)
        {
            var connectionString = ConnectivityService.GetConnectionString("TEMP");
            var context          = new BookOrganizer2DbContext(connectionString);
            var repository       = new AuthorRepository(context);

            var authorService = new AuthorService(repository);
            var command       = new Commands.SetNotesOld
            {
                Id       = id,
                NotesOld = notes
            };

            return(authorService.Handle(command));
        }
コード例 #20
0
        public static Task UpdateAuthorBiography(AuthorId id, string bio)
        {
            var connectionString = ConnectivityService.GetConnectionString("TEMP");
            var context          = new BookOrganizer2DbContext(connectionString);
            var repository       = new AuthorRepository(context);

            var authorService = new AuthorService(repository);
            var command       = new Commands.SetBiography
            {
                Id        = id,
                Biography = bio
            };

            return(authorService.Handle(command));
        }
コード例 #21
0
        public static Task UpdateAuthorMugshotPath(AuthorId id, string path)
        {
            var connectionString = ConnectivityService.GetConnectionString("TEMP");
            var context          = new BookOrganizer2DbContext(connectionString);
            var repository       = new AuthorRepository(context);

            var authorService = new AuthorService(repository);
            var command       = new Commands.SetMugshotPath
            {
                Id          = id,
                MugshotPath = path
            };

            return(authorService.Handle(command));
        }
コード例 #22
0
        public static Task UpdateAuthorDateOfBirth(AuthorId id, DateTime dob)
        {
            var connectionString = ConnectivityService.GetConnectionString("TEMP");
            var context          = new BookOrganizer2DbContext(connectionString);
            var repository       = new AuthorRepository(context);

            var authorService = new AuthorService(repository);
            var command       = new Commands.SetAuthorDateOfBirth
            {
                Id          = id,
                DataOfBirth = dob
            };

            return(authorService.Handle(command));
        }
コード例 #23
0
        public static Task UpdateReadDates(BookId bookId, List <BookReadDate> readDates)
        {
            var connectionString = ConnectivityService.GetConnectionString("TEMP");
            var context          = new BookOrganizer2DbContext(connectionString);
            var repository       = new BookRepository(context);

            var bookService = new BookService(repository);
            var command     = new Commands.SetBookReadDates
            {
                Id            = bookId,
                BookReadDates = readDates
            };

            return(bookService.Handle(command));
        }
コード例 #24
0
        internal static Task UpdateLanguage(Language sut)
        {
            var connectionString = ConnectivityService.GetConnectionString("TEMP");
            var context          = new BookOrganizer2DbContext(connectionString);
            var repository       = new LanguageRepository(context);

            var languageService = new LanguageService(repository);
            var command         = new Commands.Update
            {
                Id   = sut.Id,
                Name = sut.Name
            };

            return(languageService.Handle(command));
        }
コード例 #25
0
        public static Task UpdateAuthors(BookId bookId, List <Author> authors)
        {
            var connectionString = ConnectivityService.GetConnectionString("TEMP");
            var context          = new BookOrganizer2DbContext(connectionString);
            var repository       = new BookRepository(context);

            var bookService = new BookService(repository);
            var command     = new Commands.SetAuthors
            {
                Id      = bookId,
                Authors = authors
            };

            return(bookService.Handle(command));
        }
コード例 #26
0
        internal static Task UpdateFormat(Format sut)
        {
            var connectionString = ConnectivityService.GetConnectionString("TEMP");
            var context = new BookOrganizer2DbContext(connectionString);
            var repository = new FormatRepository(context);

            var formatService = new FormatService(repository);
            var command = new Commands.Update
            {
                Id = sut.Id,
                Name = sut.Name
            };

            return formatService.Handle(command);
        }
コード例 #27
0
        public static Task UpdateLanguage(BookId bookId, Language language)
        {
            var connectionString = ConnectivityService.GetConnectionString("TEMP");
            var context          = new BookOrganizer2DbContext(connectionString);
            var repository       = new BookRepository(context);

            var bookService = new BookService(repository);
            var command     = new Commands.SetLanguage
            {
                Id       = bookId,
                Language = language
            };

            return(bookService.Handle(command));
        }
コード例 #28
0
        public static Task UpdatePublisher(BookId bookId, Publisher publisher)
        {
            var connectionString = ConnectivityService.GetConnectionString("TEMP");
            var context          = new BookOrganizer2DbContext(connectionString);
            var repository       = new BookRepository(context);

            var bookService = new BookService(repository);
            var command     = new Commands.SetPublisher
            {
                Id        = bookId,
                Publisher = publisher
            };

            return(bookService.Handle(command));
        }
コード例 #29
0
        public static Task UpdateAuthorLastName(AuthorId id, string lastName)
        {
            var connectionString = ConnectivityService.GetConnectionString("TEMP");
            var context          = new BookOrganizer2DbContext(connectionString);
            var repository       = new AuthorRepository(context);

            var authorService = new AuthorService(repository);
            var command       = new Commands.SetAuthorsLastName
            {
                Id       = id,
                LastName = lastName
            };

            return(authorService.Handle(command));
        }
コード例 #30
0
        public static Task UpdateFormats(BookId bookId, List <Format> formats)
        {
            var connectionString = ConnectivityService.GetConnectionString("TEMP");
            var context          = new BookOrganizer2DbContext(connectionString);
            var repository       = new BookRepository(context);

            var bookService = new BookService(repository);
            var command     = new Commands.SetFormats
            {
                Id      = bookId,
                Formats = formats
            };

            return(bookService.Handle(command));
        }