// 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(); }
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(); } }
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); } }
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; }
public T ReturnResponse <T>(T obj, WebAPIResponses response) { using (var waContext = new WebAPIContext()) { waContext.RecordResponse(response, DateTime.Now.Subtract(_startTime).TotalSeconds); } return(obj); }
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); }
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); }
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); } }
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); } }
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"; }
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(); } }
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"; }
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); }
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)); } } }
public void Register(WebAPIContext sharePointServiceContext) { WebAPIHelper.AddToCache(sharePointServiceContext); }
public GalleriesController(WebAPIContext context) { _context = context; }
public MediaController(WebAPIContext context) { _context = context; }
public ClassesController(WebAPIContext context) { _context = context; }
public StatusController(WebAPIContext context) { _context = context; }
public SupplierRepository(WebAPIContext db) { this.db = db; }
public CarsController(WebAPIContext context) { _context = context; }
public CategoriesController(WebAPIContext context) { _context = context; }
/// <summary> /// Constructor de la clase User /// </summary> public RepositoryUserBase(WebAPIContext dbContext) { _efRepository = new EFRepository(dbContext); }
public UserRepository(WebAPIContext context) : base(context) { mWebAPIContext = context; }
public AgreementController(WebAPIContext context) { _context = context; }
public GenericRepository(WebAPIContext context) { this.context = context; }
public ProcedureModelsController(WebAPIContext context) { _context = context; }
public BrandsController(WebAPIContext context) { _context = context; }
public RepositoryUser(WebAPIContext dbContext) : base(dbContext) { }