예제 #1
0
        public void ConfigureServices(IServiceCollection services)
        {
            // инициируем базу данных
            InitialDatabase.Local();

            // добавляем возможность кроссдоменных запросов
            services.AddCors(options => options.AddPolicy("AlowAll", builder => builder.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod()));

            // добавляем проверку запроса и устанавливаем параметры сериализации классов в запросах и ответах
            services.AddControllers(options => { options.Filters.Add(typeof(ValidatorActionFilter)); })
            .AddNewtonsoftJson(options => options.SerializerSettings.ContractResolver = new DefaultContractResolver())
            .SetCompatibilityVersion(CompatibilityVersion.Version_3_0);
        }
예제 #2
0
        public virtual void Setup()
        {
            var options = new DbContextOptionsBuilder <InitialDatabase>()
                          .UseInMemoryDatabase(databaseName: "Initial_Api")
                          .Options;

            DbContext = new InitialDatabase(options)
            {
                IsTest = true
            };

            DbContext.Seed();

            AppSettings = AppSettings.Default;

            AccountService = new AccountService(new AccountRepository(DbContext), AppSettings);

            AccountService.IsValid(CryptoHelper.Guid("U$1"), out AccountTicket accountTicket);

            AccountTicket = accountTicket;
        }
예제 #3
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();

            services.AddMediatR(Assembly.GetExecutingAssembly());

            services.AddMvc(
                config => config.ModelBinderProviders.Insert(0, new TelegramBotBinderProvider())
                );

            var http = new HttpClient();
            var bot  = new TelegramBotClient("Api Token", http);

            services.AddSingleton(http);
            services.AddSingleton(bot);
            Task.Run(async() =>
            {
                await bot.SetWebhookAsync("https://5c11946c.ngrok.io/api/update");
            });

            InitialDatabase.Init();
        }
예제 #4
0
 public AreaRepository(InitialDatabase database)
     : base(database)
 {
 }
예제 #5
0
 public CustomerRepository(InitialDatabase database)
     : base(database)
 {
 }
예제 #6
0
 public GroupRepository(InitialDatabase database)
     : base(database)
 {
 }
예제 #7
0
 public static void Main()
 {
     // заполняем начальными данными
     InitialDatabase.LocalData();
 }
예제 #8
0
 public PrivateRepository(InitialDatabase database)
 {
     _database = database;
 }
예제 #9
0
 public AccountRepository(InitialDatabase database)
     : base(database)
 {
 }
예제 #10
0
 public EnterpriseRepository(InitialDatabase database)
     : base(database)
 {
 }
예제 #11
0
 public Repository(InitialDatabase database)
 {
     _database = database;
 }