コード例 #1
0
ファイル: UserPo.cs プロジェクト: Marbulinek/NIS
 /// <summary>
 /// Loads the po.
 /// </summary>
 /// <param name="user">The user.</param>
 public void LoadPo(UserDto user)
 {
     Name = user.UserName;
     LastLogin = user.LastLogin;
     LastName = user.LastName;
     FirstName = user.FirstName;
     Email = user.Email;
     BirthNumber = user.BirthNumber;
     this.ProfesionId=user.ProfessionId;
     foreach (GroupDto group in user.Groups)
     {
         GroupPo groupPo=new GroupPo();
         groupPo.LoadPo(group);
         this.Groups.Add(groupPo);
     }
     foreach (PermissionDto permission in user.Permissions)
     {
         PermissionPo permissionPo=new PermissionPo();
         permissionPo.Id = permission.Id;
         permissionPo.Name = permission.Name;
         permissionPo.Enabled = permission.Enabled;
         Permissions.Add(permissionPo);
     }
     this.Groups.ClearChanges();
     this.Permissions.ClearChanges();
 }
コード例 #2
0
ファイル: UserPo.cs プロジェクト: Marbulinek/NIS
        /// <summary>
        /// Transforms to entity.
        /// </summary>
        /// <param name="user">The user.</param>
        /// <returns></returns>
        public UserDto TransformToEntity(UserDto user)
        {
            user.UserName = Name;
            user.LastLogin = LastLogin;
            //if(user.UserProfile==null)
            //    user.UserProfile=new UserProfile();
            user.LastName = LastName;
            user.FirstName = FirstName;
            user.Email = Email;
            user.BirthNumber = BirthNumber;
            user.ProfessionId = ProfesionId;
            
          //  user. = user.UserProfile.ProfessionId;

            //foreach (TrackedChange<GroupPo> groupPo in Groups.GetChanges())
            //{
            //    if(groupPo.State== PoState.Added)
            //        user.Groups.Add(groupPo.Entity.TransformToEntity(new Group()));
            //    if(groupPo.State==PoState.Deleted)
            //        user.Groups.Remove(user.Groups.First(x=>x.Id==groupPo.Entity.Id));
            //}
            
            //foreach (GroupPo item in Groups)
            //{
            //    if (user.Groups.FirstOrDefault(x => x.Id == item.Id) == null)
            //    {
            //        _context.UsersInGroups.Add(new Server.Model.UsersInGroup { GroupId = (short)item.GroupId, UsersId = UserId });
            //    }
            //}

            //foreach (var item in _userEntity.UsersInGroup)
            //{
            //    if (User.UsersInGroup.FirstOrDefault(x => x.GroupId == item.GroupId) == null)
            //    {
            //        _context.UsersInGroups.Remove(item);
            //    }
            //}

            return user;
        }