public MembershipUser CreateUser(string email, string password)
        {
            var membershipUser = GetUser(email, false);

            if (membershipUser != null)
            {
                return(null);
            }

            try
            {
                using (var db = new InformationalVaultsContext())
                {
                    var role = db.Roles.First(x => x.Name.ToLower() == "user");
                    var user = new User(email, password, role.Id);

                    db.Users.Add(user);
                    db.SaveChanges();
                    membershipUser = GetUser(email, false);
                    return(membershipUser);
                }
            }
            catch (Exception e)
            {
                return(null);
            }
        }
Beispiel #2
0
        public override void CreateRole(string roleName)
        {
            var newRole = new Role(roleName);
            var db      = new InformationalVaultsContext();

            db.Roles.Add(newRole);
            db.SaveChanges();
        }
Beispiel #3
0
 public void Commit()
 {
     _context.SaveChanges();
 }