Example #1
0
        public async Task <AdminResponse> DeleteAdmin(int adminId)
        {
            _logger.LogInfo("Trying to delete admin");
            try
            {
                //Get active admin user by id
                AdminUser user = await _adminUserRepo.GetAdminUserById(adminId);

                if (user == null)
                {
                    throw new Exception(string.Format(_messageHandler.GetMessage(ErrorMessagesEnum.AuthUserDoesNotExists)));
                }

                //Soft deleted
                user.IsActive = false;

                //Updated admin user
                _adminUserRepo.UpdateAdmin(user);
                _logger.LogInfo("Admin deleted");
                return(new AdminResponse(true, string.Format(_messageHandler.GetSuccessMessage(SuccessMessagesEnum.SuccessfullyDeleted))));
            }
            catch (Exception ex)
            {
                _logger.LogError("Failed to delete admin");
                return(new AdminResponse(false, ex.Message));
            }
        }