May I put ApplicationUser in the Shared project of WASM solution or there should be some kind of proxy DTO instead?

Viewed 151

In the Shared project I have model class:

public class ItemListing
{
    public Guid Id { get; set; }
    public ApplicationUser User { get; set; }//author of the listing
    public string Description { get; set; }
}

the ApplicationUser : IdentityUser class resides in the Server project.

Can I:

  1. Move the ApplicationUser class to the Shared project so I can refer to it in ItemListing class?
  2. Add reference to the Server project in the Shared project.
  3. Create ApplicationUserDTO in the Shared project that would contain subset of properties of ApplicationUser, but then how do I need some kind of mapping?
1 Answers

Can I Move the ApplicationUser class to the Shared project so I can refer to it in ItemListing class?

Yes, you could. The base class is in the Microsoft.Extensions.Identity.Stores package.

But you shouldn't. It would add some unnecessary bagage to the shared DLL and it would expose a lot of security related fields to the client.

Can I Create ApplicationUserDTO in the Shared project

That would be the efficient and safe approach. You can use for instance AutoMapper to do the conversion, although it would barely be needed.

Related