Esempio n. 1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, WebAPIContext context, UserManager <User> userManager, RoleManager <AppRole> roleManager)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }



            app.UseHttpsRedirection();

            app.UseRouting();

            app.UseCors(_corsePolicyString);

            app.UseAuthentication();    // Identifies who is who. For Identity features. Must be added BEFORE Authorization!!!

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });

            // Activate SSL
            app.UseRewriter(new RewriteOptions().AddRedirectToHttpsPermanent());

            // Add a default Admin account and Roles!
            AdminAccountAndRoles.Initialize(context, userManager, roleManager).Wait();
        }
Esempio n. 2
0
        public StuffsController(WebAPIContext context)
        {
            _context = context;
            if (!_context.Stuff.Any())
            {
                _context.Stuff.Add(new Stuff {
                    FirstName = "Иван", LastName = "Иванов", CreatedDateTime = DateTime.Now, DivisionId = 1
                });
                _context.Stuff.Add(new Stuff {
                    FirstName = "Яна", LastName = "Константинова", CreatedDateTime = DateTime.Now, DivisionId = 1
                });
                _context.Stuff.Add(new Stuff {
                    FirstName = "Петр", LastName = "Васильев", CreatedDateTime = DateTime.Now, DivisionId = 2
                });
                _context.Stuff.Add(new Stuff {
                    FirstName = "Мария", LastName = "Стронцева", CreatedDateTime = DateTime.Now, DivisionId = 2
                });

                _context.Division.Add(new Division {
                    Name = "Краснодар", CreatedDateTime = DateTime.Now
                });
                _context.Division.Add(new Division {
                    Name = "Москва", CreatedDateTime = DateTime.Now
                });

                _context.SaveChanges();
            }
        }
Esempio n. 3
0
        public void Add_Loan()
        {
            //ARRANGE: Create a new in memory DB for testing Add_Loans
            var options = new DbContextOptionsBuilder <WebAPIContext>()
                          .UseInMemoryDatabase(databaseName: "TestDb")
                          .Options;

            //ACT: Using one instance of the context
            using (var context = new WebAPIContext(options))
            {
                var service = new LoanRepository <Loan>(context);
                service.Add(new Loan
                {
                    BorrowerFirstName = "Hello",
                    BorrowerLastName  = "Test",
                    RepaymentAmount   = 500.7,
                    FundingAmount     = 250.55
                });
                context.SaveChanges();
            }

            //ASSERT: Using a seperate instance of the context, verify
            using (var context = new WebAPIContext(options))
            {
                Assert.Equal("Hello",
                             context.Loans.Single().BorrowerFirstName);
            }
        }
Esempio n. 4
0
 public UsersController(WebAPIContext context, UserManager <User> userManager, SignInManager <User> signInManager, RoleManager <AppRole> roleManager, IConfiguration configure)
 {
     _context           = context;
     this.userManager   = userManager;
     this.signInManager = signInManager;
     this.roleManager   = roleManager;
     this._configure    = configure;
 }
Esempio n. 5
0
        public T ReturnResponse <T>(T obj, WebAPIResponses response)
        {
            using (var waContext = new WebAPIContext()) {
                waContext.RecordResponse(response, DateTime.Now.Subtract(_startTime).TotalSeconds);
            }

            return(obj);
        }
Esempio n. 6
0
        private static void HandleWebRequest(WebAPIContext context)
        {
            var flags = WebStatsRequestFlags.Server | WebStatsRequestFlags.Stats;

            if (context.Request.Queries.Count > 0)
            {
                if (context.Request.Queries["flags"] != null)
                {
                    var f = context.Request.Queries["flags"];
                    int v;

                    if (f.StartsWith("0x"))
                    {
                        if (!Int32.TryParse(f.Substring(2), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out v) || v < 0)
                        {
                            v = 0;
                        }
                    }
                    else if (!Int32.TryParse(f, out v) || v < 0)
                    {
                        v = 0;
                    }

                    flags = (WebStatsRequestFlags)v;
                }
                else
                {
                    bool?server = null, stats = null;

                    foreach (var q in context.Request.Queries)
                    {
                        var value = !q.Value.EqualsAny(true, "false", "no", "off", "disabled", "0", String.Empty);

                        if (Insensitive.Equals(q.Key, "server"))
                        {
                            server = value;
                        }
                        else if (Insensitive.Equals(q.Key, "stats"))
                        {
                            stats = value;
                        }
                    }

                    if (server != null && !server.Value)
                    {
                        flags &= ~WebStatsRequestFlags.Server;
                    }

                    if (stats != null && !stats.Value)
                    {
                        flags &= ~WebStatsRequestFlags.Stats;
                    }
                }
            }

            context.Response.Data = GetJson(flags, false);
        }
Esempio n. 7
0
        private static void HandleIPN(WebAPIContext context)
        {
            var test = context.Request.Queries["test"] != null || Insensitive.Contains(context.Request.Data, "test_ipn=1");

            var endpoint = test ? "ipnpb.sandbox." : "ipnpb.";

            var paypal = String.Format("https://{0}paypal.com/cgi-bin/webscr", endpoint);

            WebAPI.BeginRequest(paypal, "cmd=_notify-validate&" + context.Request.Data, BeginVerification, EndVerification);
        }
Esempio n. 8
0
 public HttpResponseMessage Post([FromBody] Course course)
 {
     using (WebAPIContext con = new WebAPIContext())
     {
         con.Courses.Add(course);
         con.SaveChanges();
         var msg = Request.CreateResponse(HttpStatusCode.Created, course);
         return(msg);
     }
 }
Esempio n. 9
0
 public HttpResponseMessage Post([FromUri] Brand brand)
 {
     using (WebAPIContext conn = new WebAPIContext())
     {
         conn.Brands.Add(brand);
         conn.SaveChanges();
         var msg = Request.CreateResponse(HttpStatusCode.Created, brand);
         return(msg);
     }
 }
Esempio n. 10
0
        private static void HandleWebForm(WebAPIContext context)
        {
            if (!CMOptions.WebForm.Enabled)
            {
                context.Response.Data   = String.Empty;
                context.Response.Status = HttpStatusCode.NoContent;
                return;
            }

            context.Response.Data        = CMOptions.WebForm.Generate();
            context.Response.ContentType = "html";
        }
Esempio n. 11
0
 public StoreService(ICategoriesRepository CategoriesRepository,
                     IDynamicFormsRepository DynamicFormsRepository,
                     ICachedResourceStatisticsRepository CachedResourceStatisticsRepository,
                     ICacheService CacheService,
                     DbContext context)
 {
     this.CachedResourceStatisticsRepository = CachedResourceStatisticsRepository;
     this.CategoriesRepository   = CategoriesRepository;
     this.DynamicFormsRepository = DynamicFormsRepository;
     this.CacheService           = CacheService;
     this.context = (WebAPIContext)context;
 }
        public WebApplicationController(WebAPIContext context)
        {
            _context = context;

            if (_context.Spies.Count() == 0)
            {
                // Create a new TodoItem if collection is empty,
                // which means you can't delete all TodoItems.
                _context.Spies.Add(new Spies {
                    Name = "James Bond"
                });
                _context.SaveChanges();
            }
        }
Esempio n. 13
0
        private static void HandleAccountCheck(WebAPIContext context)
        {
            if (!String.IsNullOrWhiteSpace(context.Request.Queries["username"]))
            {
                var acc = Accounts.GetAccount(context.Request.Queries["username"]);

                context.Response.Data = acc != null ? "VALID" : "INVALID";
            }
            else
            {
                context.Response.Data = "INVALID";
            }

            context.Response.ContentType = "txt";
        }
Esempio n. 14
0
        public static WebAPIContext GetWideWorldImportersDbContext(string dbName)
        {
            // Create options for DbContext instance
            var options = new DbContextOptionsBuilder <WebAPIContext>()
                          .UseInMemoryDatabase(databaseName: dbName)
                          .Options;

            // Create instance of DbContext
            var dbContext = new WebAPIContext(options);

            // Add entities in memory
            dbContext.Seed();

            return(dbContext);
        }
Esempio n. 15
0
        public JsonResult GetEmployeeDetails(string FromDate, String ToDate)
        {
            using (WebAPIContext data = new WebAPIContext())
            {
                try
                {
                    var ndata = (from e in data.Employee.ToList()
                                 join a in data.Attendance.ToList() on e.Id equals a.Employeeid
                                 join o in data.OtData.ToList() on e.Id equals o.Employeeid
                                 where DateTime.Parse(a.Shiftdate) >= DateTime.Parse(FromDate) && DateTime.Parse(a.Shiftdate) <= DateTime.Parse(ToDate)
                                 select new
                    {
                        EmployeeID = e.Id,
                        EmployeeName = e.Name,
                        ShiftDate = a.Shiftdate,
                        InTime = a.Intime,
                        OutTime = a.Outtime,
                        NormalOT = o.Normalot,
                        PremiumOT = o.Premiumot
                    }).ToList();

                    data.Dispose();

                    if (ndata.Count > 0)
                    {
                        return(new JsonResult(ndata));
                    }
                    else
                    {
                        return(new JsonResult("No data found.."));
                    }
                }
                catch (Exception ex)
                {
                    return(new JsonResult(ex.Message));
                }
            }
        }
Esempio n. 16
0
 public void Register(WebAPIContext sharePointServiceContext)
 {
     WebAPIHelper.AddToCache(sharePointServiceContext);
 }
 public GalleriesController(WebAPIContext context)
 {
     _context = context;
 }
Esempio n. 18
0
 public MediaController(WebAPIContext context)
 {
     _context = context;
 }
 public ClassesController(WebAPIContext context)
 {
     _context = context;
 }
Esempio n. 20
0
 public StatusController(WebAPIContext context)
 {
     _context = context;
 }
Esempio n. 21
0
 public SupplierRepository(WebAPIContext db)
 {
     this.db = db;
 }
Esempio n. 22
0
 public CarsController(WebAPIContext context)
 {
     _context = context;
 }
Esempio n. 23
0
 public CategoriesController(WebAPIContext context)
 {
     _context = context;
 }
Esempio n. 24
0
 /// <summary>
 /// Constructor de la clase User
 /// </summary>
 public RepositoryUserBase(WebAPIContext dbContext)
 {
     _efRepository = new EFRepository(dbContext);
 }
Esempio n. 25
0
 public UserRepository(WebAPIContext context)
     : base(context)
 {
     mWebAPIContext = context;
 }
Esempio n. 26
0
 public AgreementController(WebAPIContext context)
 {
     _context = context;
 }
Esempio n. 27
0
 public GenericRepository(WebAPIContext context)
 {
     this.context = context;
 }
Esempio n. 28
0
 public ProcedureModelsController(WebAPIContext context)
 {
     _context = context;
 }
Esempio n. 29
0
 public BrandsController(WebAPIContext context)
 {
     _context = context;
 }
Esempio n. 30
0
 public RepositoryUser(WebAPIContext dbContext) : base(dbContext)
 {
 }