Ejemplo n.º 1
0
 public UnitOfWork(DefaultDBContext context)
 {
     _context     = context;
     Items        = new ItemRepository(_context);
     Categories   = new CategoryRepository(_context);
     Navigations  = new NavigationRepository(_context);
     ItemContents = new ItemContentRepository(_context);
 }
Ejemplo n.º 2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, DefaultDBContext dbContext, IHostingEnvironment env)
        {
            app.UseExceptionHandler(errorApp =>
            {
                errorApp.Run(async context =>
                {
                    context.Response.ContentType = "application/json";

                    var exceptionHandlerFeature = context.Features.Get <IExceptionHandlerFeature>();

                    logger.Log(LogLevel.Error, exceptionHandlerFeature.Error, exceptionHandlerFeature.Error.Message);

                    await context.Response.WriteAsync(JsonConvert.SerializeObject(CreateProblemDetails(env, context, exceptionHandlerFeature.Error)));
                });
            });


            try
            {
                dbContext.Database.Migrate();
            }
            catch (Exception e)
            {
                logger.LogError(e, "Unable to migrate the database");
                throw;
            }

            app.UseHsts();
            app.UseHttpsRedirection();

            // Enable middleware to serve generated Swagger as a JSON endpoint.
            app.UseSwagger();

            // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.),
            // specifying the Swagger JSON endpoint.
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
                c.RoutePrefix = string.Empty;
            });

            app.UseMvc();
        }
Ejemplo n.º 3
0
        public ActionResult ExternalLoginConfirmation(RegisterExternalLoginModel model, string returnUrl)
        {
            string provider       = null;
            string providerUserId = null;

            if (User.Identity.IsAuthenticated || !OAuthWebSecurity.TryDeserializeProviderUserId(model.ExternalLoginData, out provider, out providerUserId))
            {
                return(RedirectToAction("Manage"));
            }

            if (ModelState.IsValid)
            {
                // Insert a new user into the database
                using (DefaultDBContext db = new DefaultDBContext())
                {
                    UserProfile user = db.UserProfiles.FirstOrDefault(u => u.UserName.ToLower() == model.UserName.ToLower());
                    // Check if user already exists
                    if (user == null)
                    {
                        // Insert name into the profile table
                        db.UserProfiles.Add(new UserProfile {
                            UserName = model.UserName
                        });
                        db.SaveChanges();

                        OAuthWebSecurity.CreateOrUpdateAccount(provider, providerUserId, model.UserName);
                        OAuthWebSecurity.Login(provider, providerUserId, createPersistentCookie: false);

                        return(RedirectToLocal(returnUrl));
                    }
                    else
                    {
                        ModelState.AddModelError("UserName", "User name already exists. Please enter a different user name.");
                    }
                }
            }

            ViewBag.ProviderDisplayName = OAuthWebSecurity.GetOAuthClientData(provider).DisplayName;
            ViewBag.ReturnUrl           = returnUrl;
            return(View(model));
        }
            public SimpleMembershipInitializer()
            {
                Database.SetInitializer <DefaultDBContext>(null);

                try
                {
                    using (var context = new DefaultDBContext())
                    {
                        if (!context.Database.Exists())
                        {
                            // Create the SimpleMembership database without Entity Framework migration schema
                            ((IObjectContextAdapter)context).ObjectContext.CreateDatabase();
                        }
                    }

                    WebSecurity.InitializeDatabaseConnection("DefaultConnection", "UserProfile", "UserId", "UserName", autoCreateTables: true);
                }
                catch (Exception ex)
                {
                    throw new InvalidOperationException("The ASP.NET Simple Membership database could not be initialized. For more information, please see http://go.microsoft.com/fwlink/?LinkId=256588", ex);
                }
            }
Ejemplo n.º 5
0
 public NavigationRepository(DefaultDBContext context) : base(context)
 {
 }
Ejemplo n.º 6
0
 public CategoryRepository(DefaultDBContext context) : base(context)
 {
 }
Ejemplo n.º 7
0
 public DefaultService()
 {
     _context = new DefaultDBContext();
 }
Ejemplo n.º 8
0
 public DaoParagraphe(DefaultDBContext context) : base(context)
 {
 }
Ejemplo n.º 9
0
 protected Repository(DefaultDBContext db)
 {
     Db    = db;
     DbSet = db.Set <TEntity>();
 }
Ejemplo n.º 10
0
 public ItemContentRepository(DefaultDBContext context) : base(context)
 {
 }
Ejemplo n.º 11
0
 public DaoAccess(DefaultDBContext context)
 {
     this._context = context;
 }
Ejemplo n.º 12
0
 public DaoReponse(DefaultDBContext context) : base(context)
 {
 }
 public ProductRepository(DefaultDBContext dbContext) : base(dbContext)
 {
 }
 public AccountRepository(DefaultDBContext defaultDbContext)
 {
     this.defaultDbContext = defaultDbContext
                             ?? throw new ArgumentNullException(nameof(defaultDbContext));
 }
Ejemplo n.º 15
0
 public DaoQuestion(DefaultDBContext context) : base(context)
 {
 }
Ejemplo n.º 16
0
 public DaoAventure(DefaultDBContext context) : base(context)
 {
 }