Asp.Net Boilerplate... How to update a record in Existing tables in Database using Async methods?

1.8k views Asked by At

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?

1

There are 1 answers

1
Alper Ebicoglu On

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);
        }
}