Exemple #1
0
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, GuardianContext guardianContext)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            if (Configuration.GetValue("UseHttpsRedirection", defaultValue: true) is true)
            {
                app.UseHttpsRedirection();
            }

            app.UseRouting();

            app.UseCors("AllowConfiguredOrigins");

            app.UseAuthorization();

            app.UseSwagger();

            app.UseSwaggerUI(c => {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "Guardian API V1");
            });

            app.UseEndpoints(endpoints => {
                endpoints.MapControllers();
            });
        }
Exemple #2
0
 public AuthRepository(GuardianContext guardianContext)
 {
     if (guardianContext == null)
     {
         throw new ArgumentException("guardianContext");
     }
     _guardianContext = guardianContext;
 }
Exemple #3
0
        /// <summary>
        /// Returns a Task that executes the work that will ultimately respond to the request.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        internal Task HandleRequest(GuardianContext context)
        {
            // Instantiate controller and execute the target method with the deserialized parameters
            object    controllerInstance = Activator.CreateInstance(ControllerMethodInfo.ReflectedType);
            IResponse response           = (IResponse)ControllerMethodInfo.Invoke(controllerInstance, Parameters);

            // Return a Task that will return the actual response to the client
            return(Task.Factory.StartNew(() => response.Execute(context)));
        }
Exemple #4
0
        public void Execute(GuardianContext context)
        {
            context.Response.ContentType = ContentType;
            context.Response.SetExpire(DateTimeOffset.UtcNow.AddMinutes(1));

            string serialized = JsonConvert.SerializeObject(_payload);

            byte[] bytes = Encoding.UTF8.GetBytes(serialized);
            new MemoryStream(bytes).CopyTo(context.Response.Body);
        }
 public void DeleteUsingEFTest()
 {
     using (var ctx = new GuardianContext())
     {
         //User u = new User() { Name = "VR" };//Not working
         User u = new User()
         {
             UserID = 2
         };                               // working
         ctx.Entry(u).State = EntityState.Deleted;
         ctx.SaveChanges();
     }
 }
        public void TestMethod1()
        {
            using (var ctx = new GuardianContext())
            {
                User u = new User();
                u.Email = "*****@*****.**";
                u.Name  = "VR";
                ctx.Users.Add(u);
                ctx.SaveChanges();

                Profile pr = new Profile();
                pr.User       = u;
                pr.RegionCode = "+91";
                ctx.Profiles.Add(pr);

                ctx.SaveChanges();
            }
        }
Exemple #7
0
        public void Execute(GuardianContext context)
        {
            context.Response.ContentType = ContentType;
            context.Response.SetExpire(DateTimeOffset.UtcNow.AddMinutes(1));

            var executingAssembly = ReflectionHelper.GetExecutingAssembly();
            var pagePath          = $"{executingAssembly.GetName().Name}.{_path}.html"; //TODO: Some hardcoded magic here.

            using (var inputStream = executingAssembly.GetManifestResourceStream(pagePath))
            {
                if (inputStream == null)
                {
                    throw new ArgumentException($"Page, '{_path}' not found in assembly {executingAssembly}.");
                }

                inputStream.CopyTo(context.Response.Body);
            }
        }
        public void Execute(GuardianContext context)
        {
            context.Response.ContentType = ContentType;
            context.Response.SetExpire(DateTimeOffset.UtcNow.AddMinutes(1));

            Assembly executingAssembly     = ReflectionHelper.GetExecutingAssembly();
            string   executingAssemblyName = executingAssembly.GetName().Name;
            string   resourcePath          = $"{executingAssemblyName}.Content.app.dist.guardian.resources.{_resourceName}"; //TODO: Some hardcoded magic here.

            using (var inputStream = executingAssembly.GetManifestResourceStream(resourcePath))
            {
                if (inputStream == null)
                {
                    throw new ArgumentException($"Resource, '{resourcePath}' not found in assembly {executingAssembly}.");
                }

                inputStream.CopyTo(context.Response.Body);
            }
        }
Exemple #9
0
 public SystemsController(GuardianContext context)
 {
     _context = context;
 }
Exemple #10
0
 public ModulesController(GuardianContext context)
 {
     _context = context;
 }
Exemple #11
0
 public SystemRepository(GuardianContext guardianContext)
 {
     _guardianContext = guardianContext;
 }