-5

I am working with ASP.Net Boilerplate. I want to send isActive=true to the AbpUser table when a user is confirmed by email. How can I access the database and do a query on that?

As you know Boilerplate doesn't provide entity classes so I am working with extensions on those classes. I don't know how queries on those classes access the database. Any idea?

Mesam Mujtaba
  • 114
  • 12
  • why do you think ABP doesn't provide entity classes. you have to read the docs.. https://aspnetboilerplate.com/Pages/Documents/Entities?searchKey=entity – Alper Ebicoglu Aug 28 '17 at 08:40

1 Answers1

2

I wrote a sample code to show you how you can update a field of user with IRepository.

public interface IUserAppService: IApplicationService
{
    void ActivateUser(int userId);
}

 public class UserAppService : IUserAppService
    {
        private readonly IRepository<User, long> _userRepository;

        public UserEmailer(IRepository<User, long> userRepository)
        {
            _userRepository = userRepository;
        }

        public void ActivateUser(int userId)
        {
            var user = _userRepository.Get(userId);
            user.IsActive = true;
            _userRepository.Update(user);
        }
}
Alper Ebicoglu
  • 8,884
  • 1
  • 49
  • 55
  • 2
    It's the way to go! PO must know that when the Entity have a ID type other than "int" it must provide the type as second argument to the repository. – Vince Aug 28 '17 at 18:46