Exemplo n.º 1
0
        public async Task <ExecutionResponse <UserModel> > ToggleActivateUser(long Id)
        {
            var user = _userQueryRepo.GetAllIncludeInactive().FirstOrDefault(x => x.Id == Id);

            if (user == null || (CurrentCompanyId != 0 && user.CompanyId != CurrentCompanyId))
            {
                return new ExecutionResponse <UserModel>
                       {
                           ResponseCode = ResponseCode.NotFound,
                           Message      = "No record found"
                       }
            }
            ;

            user.IsActive = !user.IsActive;

            await _userCommandRepo.UpdateAsync(user);

            await _userCommandRepo.SaveChangesAsync();

            return(new ExecutionResponse <UserModel>
            {
                ResponseCode = ResponseCode.Ok,
                ResponseData = _mapper.Map <UserModel>(user)
            });
        }