private User Map(User user, UserDto dto)
        {
            user.Username = dto.Username;
            user.Firstname = dto.Firstname;
            user.Lastname = dto.Lastname;
            user.EmailAddress = dto.EmailAddress;

            user.Roles.Clear();
            user.Groups.Clear();

            // TODO: Implementation Activation workflow
            user.IsActive = true;

            foreach (var role in dto.Roles)
            {
                user.Roles.Add(uow.Roles.GetById(role.Id));
            }

            foreach (var group in dto.Groups)
            {
                user.Groups.Add(uow.Groups.GetById(group.Id));
            }

            return user;
        }
Пример #2
0
 public UserDto(User user)
 {
     if (user != null)
     {
         this.Id = user.Id;
         this.Username = user.Username;
         this.Firstname = user.Firstname;
         this.Lastname = user.Lastname;
         this.EmailAddress = user.EmailAddress;
         this.Roles = user.Roles.Where(x => !x.IsDeleted).Select(x => new RoleDto(x)).ToList();
         this.Groups = user.Groups.Where(x => !x.IsDeleted).Select(x => new GroupDto(x)).ToList();
     }
 }
        public static void Seed(VideoOnDemandContext context)
        {
            var user = new User()
            {
                Id = 1,
                Username = "******",
                Password = "******",
                Firstname = "Quinn",
                Lastname = "Brown"
            };

            context.Users.AddOrUpdate(user);

            context.SaveChanges();
        }
 public void SignOut(User user)
 {
 }
 public Session GetSession(User user)
 {
     return uow.Sessions.GetAll().Where(x => x.UserId == user.Id).FirstOrDefault();
 }
 public TokenDto StartSession(User user)
 {
     return StartSession(user.Id);
 }