Ejemplo n.º 1
0
 public UserEditorViewModel Build()
 {
     this.User = Ioc.Get<Services.IUserService>().Get(_userId);
     var service = Ioc.Get<ITagService>();
     var userTags = service.GetUserTags(_userId);
     this.Tags = service.GetAll().ToSelectList(x => x.Name, x => x.Id, x => userTags.Any(u => u == x.Id));
     return this;
 }
Ejemplo n.º 2
0
 public void CompleteRegistration(Guid userId, User user)
 {
     using (var db = base.NewDB())
     {
         var dbUser = db.Users.Get(userId);
         dbUser.UpdateByCompleteRegistration(user);
         db.SaveChanges();
     }
 }
Ejemplo n.º 3
0
 public StandardJsonResult CompleteRegistration(User user)
 {
     return base.Try(() =>
     {
         if (string.IsNullOrWhiteSpace(user.NickName))
         {
             throw new KnownException("nickname is required");
         }
         var service = Ioc.Get<IUserService>();
         service.CompleteRegistration(GetUserId(), user);
     });
 }
Ejemplo n.º 4
0
        public void Register(string username, string password, bool registerAsAdmin)
        {
            var ip = HttpContext.Current.Request.UserHostAddress;
            var address = IpHelper.GetAddress(ip);
            using (var db = base.NewDB())
            {
                if (db.Users.Any(x => x.Username == username))
                {
                    throw new KnownException("username already exists");
                }
                var user = new User(username, CryptoService.Md5HashEncrypt(password));
                user.RegisterIp = ip;
                user.RegisterAddress = address;
                db.Users.Add(user);

                if (registerAsAdmin)
                {
                    var role = db.Roles.First(x => x.Name == Role.Names.SuperAdmin);
                    db.UserRoleRLs.Add(new UserRoleRL(user.Id, role.Id));
                }
                db.SaveChanges();
            }
        }
Ejemplo n.º 5
0
 public void UpdateByCompleteRegistration(User user)
 {
     this.NickName = user.NickName;
     this.Signature = user.Signature;
     this.Age = user.Age;
     this.Gender = user.Gender;
     this.ImageKey = user.ImageKey;
 }
Ejemplo n.º 6
0
 public SessionUser(User user, string[] roles)
 {
     this.Id = user.Id;
     this.Roles = roles;
     this.NickName = user.NickName;
 }