Asp Zero how to add DropDownlist to Users page?

287 Views Asked by At

I'm new to Asp Zero and i want to know how to add Dropdownlist and fill it from Lookups table My objective is that i have Departments and each departments will have some their documents archived on the system only one Main Department can view, edit , or add the documents. Other Departments view only the documents related to their departments so want link the Users to the departments. Thank you.

1

There are 1 best solutions below

1
On

Morgan,

You can follow this steps,

The first thing you need to do, is to add the relationship between User and Department

Go to YourProject.Core\Authotization\Users\User.cs and add to this class the DepartmentId like this.

public class User : AbpUser<User>
{
    public virtual Guid? ProfilePictureId { get; set; }

    public virtual bool ShouldChangePasswordOnNextLogin { get; set; }
    // Others propierties...

    public int? DepartmendId {get;set;}
    public virtual Department Department {get;set;}
}

The go to YourProject.Application.Shared\Authorization\Users\Dto\UserEditDto.cs

public class UserEditDto : IPassivable
{
    /// <summary>
    /// Set null to create a new user. Set user's Id to update a user
    /// </summary>
    public long? Id { get; set; }

    [Required]
    [StringLength(AbpUserBase.MaxNameLength)]
    public string Name { get; set; }

    [Required]
    [StringLength(AbpUserBase.MaxSurnameLength)]
    public string Surname { get; set; }

    // Other Properties...
    public int DepartmentId {get; set;}
}

After this create a new migration and update the database also you need to run refresh.bat file in angular project (Angular\nswag\refresh.bat) remember that Api must be running before running the .bat file.

After this, you can call DepartmentServiceProxy in app\users\create-or-edit-user-modal.component.ts to fill the DropDownList.

Then when you save the user you can select the department.