Inheritance: DbContext
Beispiel #1
0
        protected void Application_PostAuthenticateRequest(Object sender, EventArgs e)
        {
            var cu = Context.User;
            EfDbContext db = new EfDbContext();
            if (db.Users.Count() != 0 && db.Users.Any(c => c.Roles.Any(r => r.RoleName == "Администратор")))
            {

                string currentSid = null;
                var identity = Context.User.Identity as WindowsIdentity;
                if (identity.User != null) currentSid = identity.User.Value;

                SocialPackage.Infrastructure.Entities.User usr = db.Users.Include("Limit").FirstOrDefault(el => el.Login == currentSid);
                if (usr != null)
                {
                    usr.Identity = identity;
                    Context.User = usr;
                    //throw new MembershipCreateUserException("заведите пользователя в базе данных");
                }

            }
            else
            {
                var user = new User
                {
                    Roles = new List<UserRole>
                    {
                        new UserRole
                        { RoleName = "Администратор" }
                    }
                };

                user.Identity = Context.User.Identity as WindowsIdentity;
                Context.User = user;
            }
        }
 public SocialPackageSmtpClient(EfDbContext context)
     : base()
 {
     base.DeliveryMethod = SmtpDeliveryMethod.Network;
     base.Host = context.Settings.First().Host;
     base.Port = context.Settings.First().Port;
     base.Credentials = new NetworkCredential(context.Settings.First().ServiceEmailUser, context.Settings.First().ServiceEmailPassword);
 }
Beispiel #3
0
 public MailController(EfDbContext dbContext)
     : base(new SocialPackageMailSender(new SocialPackageSmtpClient(dbContext)))
 {
     this.dbContext = dbContext;
 }
Beispiel #4
0
 public OneCController()
 {
     db = new EfDbContext();
     provider = new AdUserProvider(db.Settings.First().Domain);
 }