Ejemplo n.º 1
0
        public virtual User GetCurrentUser()
        {
            if (HttpContext.Current == null || HttpContext.Current.User == null)
            {
                var userrole = new UserRole {RoleRef = (int)Role.None};
                var user = new User();

                user.UserRoles.Add(userrole);

                return user;
            }

            var identity = HttpContext.Current.User.Identity;

            if (!identity.IsAuthenticated)
            {
                return null;
            }

            var db = GetDbContext();

            return db.Users.Where(u => u.Username == identity.Name).FirstOrDefault();
        }
Ejemplo n.º 2
0
        public void RegisterUser(RegisterModel registerModel)
        {
            var db = GetDbContext();

            var userrole = new UserRole
                               {
                                   RoleRef = (int) Role.Student
                               };

            var user = new User
                            {
                                Id = Guid.NewGuid(),
                                Username = registerModel.Username,
                                Password = EncryptPassword(registerModel.Password),
                                OpenId = registerModel.OpenId ?? string.Empty,
                                Email = registerModel.Email,
                                Name = registerModel.Name,
                                IsApproved = false,
                                Deleted = false,
                                CreationDate = DateTime.Now,
                                ApprovedBy = null
                            };

            user.UserRoles.Add(userrole);

            db.Users.InsertOnSubmit(user);
            db.SubmitChanges();

            SendEmail("admin@iudico", user.Email, "Iudico Notification", "Your account has been created:\nUsername: "******"\nPassword: " + registerModel.Password);
        }
Ejemplo n.º 3
0
        public void AddUserToRole(Role role, User user)
        {
            var db = GetDbContext();

            var userRole = new UserRole { RoleRef = (int)role, UserRef = user.Id };

            db.UserRoles.InsertOnSubmit(userRole);
            db.SubmitChanges();
        }
Ejemplo n.º 4
0
 partial void DeleteUserRole(UserRole instance);
Ejemplo n.º 5
0
 partial void UpdateUserRole(UserRole instance);
Ejemplo n.º 6
0
 partial void InsertUserRole(UserRole instance);
Ejemplo n.º 7
0
		private void detach_UserRoles(UserRole entity)
		{
			this.SendPropertyChanging();
			entity.User = null;
		}
Ejemplo n.º 8
0
		private void attach_UserRoles(UserRole entity)
		{
			this.SendPropertyChanging();
			entity.User = this;
		}