Esempio 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();
        }
Esempio 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);
        }
Esempio 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();
        }
Esempio n. 4
0
 partial void DeleteUserRole(UserRole instance);
Esempio n. 5
0
 partial void UpdateUserRole(UserRole instance);
Esempio n. 6
0
 partial void InsertUserRole(UserRole instance);
Esempio n. 7
0
		private void detach_UserRoles(UserRole entity)
		{
			this.SendPropertyChanging();
			entity.User = null;
		}
Esempio n. 8
0
		private void attach_UserRoles(UserRole entity)
		{
			this.SendPropertyChanging();
			entity.User = this;
		}